opensearch-project/OpenSearch

[BUG] Resize request should throw 4xx as part of validation failure for write block

Open

#19.026 geöffnet am 11. Aug. 2025

Auf GitHub ansehen
 (1 Kommentar) (0 Reaktionen) (1 zugewiesene Person)Java (1.505 Forks)batch import
Cluster Managerbuggood first issue

Repository-Metriken

Stars
 (8.123 Stars)
PR-Merge-Metriken
 (Durchschn. Merge 5T 9h) (266 gemergte PRs in 30 T)

Beschreibung

Describe the bug

Currently as part of the resize request validation while creating a target index using MetadataCreateIndexService, it throws IllegalStateException that gets translated to 5xx. Here it should instead throw IllegalArgumentException which will be translated to 4xx. 5xx is usually treated as server side failure/error whereas 4xx will be wrong user input which fits well in this case.

Ref: https://github.com/opensearch-project/OpenSearch/blame/1a5331727b8037b4bcaf3e7c2a46dfb467259d13/server/src/main/java/org/opensearch/cluster/metadata/MetadataCreateIndexService.java#L1655

Response:

HTTP/2 500 Internal Server Error
Date: Mon, 07 Jul 2025 15:48:17 GMT
Content-Type: application/json; charset=UTF-8
Content-Length: 315
Access-Control-Allow-Origin: *

{"error":{"root_cause":[{"type":"illegal_state_exception","reason":"index test-01 must block write operations to resize index. use \"index.blocks.write=true\""}],"type":"illegal_state_exception","reason":"index test-01 must block write operations to resize index. use \"index.blocks.write=true\""},"status":500}

Related component

No response

To Reproduce

  • Submit request to shrink an existing index (test-01) without write block on it.
curl localhost:9200/test-01/_shrink/test-shrink-01

Expected behavior

OpenSearch should throw 4xx error instead of 5xx

Additional Details

N/A

Contributor Guide