Skip to content

Conversation

@romseygeek
Copy link
Contributor

Currently, if an incorrectly formatted date is passed as a null_value for a date field mapper
configuration, you get a vague error:

Failed to parse mapping [_doc]: cannot parse empty date

Similarly, if you pass an incorrect format, you get the error:

Failed to parse mapping [_doc]: Invalid format [...]

This commit improves both these errors by including the mapper name and parameter that
are misconfigured.

Fixes #61712

@romseygeek romseygeek added >enhancement :Search Foundations/Mapping Index mappings, including merging and defining field types v8.0.0 v7.10.0 v7.9.2 labels Sep 3, 2020
@romseygeek romseygeek self-assigned this Sep 3, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/Mapping)

@elasticmachine elasticmachine added the Team:Search Meta label for search team label Sep 3, 2020
@romseygeek
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/packaging-sample-windows (because that's what we're doing today, apparently)

Copy link
Contributor

@jtibshirani jtibshirani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I left some small comments, but looks good to me once those are addressed !

return new DateFieldType(buildFullName(context), index.getValue(), docValues.getValue(),
dateTimeFormatter, resolution, meta.getValue());
try {
DateFormatter dateTimeFormatter = DateFormatter.forPattern(format.getValue()).withLocale(locale.getValue());
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small comment, maybe we should scope the try/ catch down to avoid rewrapping an IllegalArgumentException from the constructor call ? It doesn't seem like a concern for this specific constructor, but seems like good practice.

try {
return formatter.parseMillis(nullValue.getValue());
}
catch (Exception e) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small comment, catch is usually on same line as previous brace.

Not relevant for this PR, but reading this made me notice that we parse null_value dates different from ones that appear in documents. Specifically, I wonder why we don't use DateFieldType#parse here ?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Specifically, I wonder why we don't use DateFieldType#parse here ?

This is a bug, I'll open a separate PR to fix.

@romseygeek
Copy link
Contributor Author

@elasticmachine update branch

@romseygeek
Copy link
Contributor Author

@elasticmachine run elasticsearch-ci/packaging-sample-windows

@romseygeek romseygeek merged commit 50a74f9 into elastic:master Sep 4, 2020
@romseygeek romseygeek deleted the mapper/empty-null-value branch September 4, 2020 13:02
romseygeek added a commit that referenced this pull request Sep 4, 2020
…te mapper (#61932)

Currently, if an incorrectly formatted date is passed as a null_value for a date field mapper
configuration, you get a vague error:

Failed to parse mapping [_doc]: cannot parse empty date
Similarly, if you pass an incorrect format, you get the error:

Failed to parse mapping [_doc]: Invalid format [...]
This commit improves both these errors by including the mapper name and parameter that
are misconfigured.

Fixes #61712
romseygeek added a commit that referenced this pull request Sep 4, 2020
…te mapper (#61932)

Currently, if an incorrectly formatted date is passed as a null_value for a date field mapper
configuration, you get a vague error:

Failed to parse mapping [_doc]: cannot parse empty date
Similarly, if you pass an incorrect format, you get the error:

Failed to parse mapping [_doc]: Invalid format [...]
This commit improves both these errors by including the mapper name and parameter that
are misconfigured.

Fixes #61712
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

>enhancement :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Meta label for search team v7.9.2 v7.10.0 v8.0.0-alpha1

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7.9 not allowing null_value in date type

4 participants