-
Notifications
You must be signed in to change notification settings - Fork 25.6k
Handle long overflow in dates #112650
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
Handle long overflow in dates #112650
Conversation
20a1d47
to
0c9b57f
Compare
Pinging @elastic/es-analytical-engine (Team:Analytics) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@elasticmachine, ok to test
server/src/main/java/org/elasticsearch/common/time/DateUtils.java
Outdated
Show resolved
Hide resolved
...c/test/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToLongTests.java
Show resolved
Hide resolved
...test/java/org/elasticsearch/xpack/esql/expression/function/scalar/convert/ToStringTests.java
Show resolved
Hide resolved
Pinging @elastic/es-search-foundations (Team:Search Foundations) |
I think it'd be nice to have a file like |
@elasticsearchmachine test this please |
server/src/main/java/org/elasticsearch/common/time/DateUtils.java
Outdated
Show resolved
Hide resolved
I'm removing myself as the |
💚 CLA has been signed |
cde2dba
to
fe1655d
Compare
server/src/main/java/org/elasticsearch/common/time/DateUtils.java
Outdated
Show resolved
Hide resolved
area: Search | ||
type: bug | ||
issues: | ||
- 112483 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think this patch solves issue #112483 though - wouldn't IllegalArgumentException
still produce 500? One would have to catch it in DateFieldMapper
and convert it to ElasticsearchParseException
to make it 4xx if I understand it correctly. Which however raises the question - if we'd have to catch it there, does it really need to be also converted in toLongMillis
(not a rhetorical question, I don't have a predetermined answer to it)?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I totally agree with this point. Now I think, the only use case of this patch can be providing better error message to the user (given that we catch it in DateFieldMapper
as well, and convert to ElasticsearchParseException
to make it 4xx)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IllegalArgumentException does normally get converted to a 400 error here: https://github.com/elastic/elasticsearch/blob/main/server/src/main/java/org/elasticsearch/ExceptionsHelper.java#L64 . Any reason why this one specifically would lead to a 500 instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wasn't aware of this and assumed IllegalArgumentException returns 500 based on previous comment. As that's not the case, I think the patch should work without additonal modification
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah maybe I was confusing it with another exception.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we have a test that verifies this? Don't just believe me :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can't verify the full circle here because the original issue did not contain reproducing example and I am not sure how to reproduce it from scratch. But this suggests @javanna is correct:
} else if (t instanceof IllegalArgumentException) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
++ sounds good.
@elasticmachine test this please |
@pulak777 looks like we have some checkstyle problems here, please fix them. Usually just running |
done |
@elasticmachine test this please |
Looks like it breaks some tests, e.g.:
|
is it possible to grant me access to see the failing tests on ci? it kinda takes forever to run all the tests on my laptop |
@pulak777 Not sure about the access, but look at |
updated the failing tests in |
@elasticmachine test this please |
@elasticmachine update branch |
@elasticmachine test this please |
@elasticmachine update branch |
@elasticmachine test this please |
Replaced by #124048 to update to current code. |
This makes sure that dates that overflow a
long
fail with a reasonable message rather than anArithmeticException
. This mostly just hits the field mapper.