Closed craigtaverner closed 1 month ago
Pinging @elastic/es-search (Team:Search)
@craigtaverner Could you provide an example of the query/date that leads to this failure?
I think something like this should fix it:
--- a/server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java
+++ b/server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java
@@ -674,7 +674,11 @@ public final class DateFieldMapper extends FieldMapper {
LongSupplier now,
Resolution resolution
) {
- return resolution.convert(dateParser.parse(BytesRefs.toString(value), now, roundUp, zone));
+ try {
+ return resolution.convert(dateParser.parse(BytesRefs.toString(value), now, roundUp, zone));
+ } catch (DateTimeException | ArithmeticException e) {
+ throw new ElasticsearchParseException("failed to parse date field [" + value + "]", e);
+ }
}
@Override
@craigtaverner Could you provide an example of the query/date that leads to this failure?
I was not able to see the query in the server logs. This was not a CI test failure, but an issue in a cloud instance. I speculate the user entered an invalid date with an invalid month, eg. "2024-0-1"
An invalid MonthOfYear value (0) caused all shard to fail, RemoteTransportExeception and a
500
http status code. We feel this should rather be a code in the 4xx range, since it is an error in the search query.