Skip to content

[8.x] ESQL: Fail with 500 not 400 for ValueExtractor bugs (#126296) #126388

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions docs/changelog/126296.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 126296
summary: Fail with 500 not 400 for `ValueExtractor` bugs
area: ES|QL
type: bug
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ interface ValueExtractor {

static ValueExtractor extractorFor(ElementType elementType, TopNEncoder encoder, boolean inKey, Block block) {
if (false == (elementType == block.elementType() || ElementType.NULL == block.elementType())) {
throw new IllegalArgumentException("Expected [" + elementType + "] but was [" + block.elementType() + "]");
// While this maybe should be an IllegalArgumentException, it's important to throw an exception that causes a 500 response.
// If we reach here, that's a bug. Arguably, the operators are in an illegal state because the layout doesn't match the
// actual pages.
throw new IllegalStateException("Expected [" + elementType + "] but was [" + block.elementType() + "]");
}
return switch (block.elementType()) {
case BOOLEAN -> ValueExtractorForBoolean.extractorFor(encoder, inKey, (BooleanBlock) block);
Expand Down