opensearch-project/OpenSearch

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

Open

#19,026 opened on 2025年8月11日

GitHub で見る
 (1 comment) (0 reactions) (1 assignee)Java (8,123 stars) (1,505 forks)batch import
Cluster Managerbuggood first issue

説明

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

コントリビューターガイド