Skip to content

Commit 99fe696

Browse files
authored
Throw IllegalArgumentException when shape field is missing during fetch (#136737)
throw an IllegalArgumentException which translates into a 400 error.
1 parent 602ae30 commit 99fe696

File tree

2 files changed

+4
-4
lines changed

2 files changed

+4
-4
lines changed

server/src/main/java/org/elasticsearch/index/query/AbstractGeometryQueryBuilder.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -362,7 +362,7 @@ private static void fetch(Client client, GetRequest getRequest, String path, Act
362362
}
363363
}
364364
}
365-
throw new IllegalStateException("Shape with name [" + getRequest.id() + "] found but missing " + path + " field");
365+
throw new IllegalArgumentException("Shape with name [" + getRequest.id() + "] found but missing " + path + " field");
366366
}
367367
} catch (Exception e) {
368368
l.onFailure(e);

x-pack/plugin/security/src/internalClusterTest/java/org/elasticsearch/integration/FieldLevelSecurityTests.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -601,10 +601,10 @@ public void testGeoQueryWithIndexedShapeWithFLS() {
601601
final ShapeQueryBuilder shapeQuery2 = new ShapeQueryBuilder("field", "2").relation(ShapeRelation.WITHIN)
602602
.indexedShapeIndex("shape_index")
603603
.indexedShapePath("other");
604-
IllegalStateException e;
604+
IllegalArgumentException e;
605605
if (randomBoolean()) {
606606
e = expectThrows(
607-
IllegalStateException.class,
607+
IllegalArgumentException.class,
608608
() -> client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user6", USERS_PASSWD)))
609609
.prepareSearch("search_index")
610610
.setQuery(QueryBuilders.matchAllQuery())
@@ -613,7 +613,7 @@ public void testGeoQueryWithIndexedShapeWithFLS() {
613613
);
614614
} else {
615615
e = expectThrows(
616-
IllegalStateException.class,
616+
IllegalArgumentException.class,
617617
() -> client().filterWithHeader(Collections.singletonMap(BASIC_AUTH_HEADER, basicAuthHeaderValue("user6", USERS_PASSWD)))
618618
.prepareSearch("search_index")
619619
.setQuery(shapeQuery2)

0 commit comments

Comments
 (0)