Skip to content

Commit 9135578

Browse files
committed
Return 404 instead of 400
1 parent 1bf5dde commit 9135578

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

rest-api-spec/src/yamlRestTest/resources/rest-api-spec/test/indices.rollover/10_basic.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@
187187
---
188188
"Rolling over an unknown target should return 404":
189189
- do:
190-
catch: bad_request
190+
catch: missing
191191
indices.rollover:
192192
alias: "non_existent"
193193
- match: {error.reason: "rollover target [non_existent] does not exist"}

server/src/main/java/org/elasticsearch/action/admin/indices/rollover/MetadataRolloverService.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import org.apache.logging.log4j.LogManager;
1313
import org.apache.logging.log4j.Logger;
14+
import org.elasticsearch.ResourceNotFoundException;
1415
import org.elasticsearch.action.admin.indices.create.CreateIndexClusterStateUpdateRequest;
1516
import org.elasticsearch.action.admin.indices.create.CreateIndexRequest;
1617
import org.elasticsearch.action.datastreams.autosharding.AutoShardingResult;
@@ -664,7 +665,7 @@ static void validate(
664665
) {
665666
final IndexAbstraction indexAbstraction = project.getIndicesLookup().get(rolloverTarget);
666667
if (indexAbstraction == null) {
667-
throw new IllegalArgumentException("rollover target [" + rolloverTarget + "] does not exist");
668+
throw new ResourceNotFoundException("rollover target [" + rolloverTarget + "] does not exist");
668669
}
669670
if (VALID_ROLLOVER_TARGETS.contains(indexAbstraction.getType()) == false) {
670671
throw new IllegalArgumentException(

0 commit comments

Comments
 (0)