-
Notifications
You must be signed in to change notification settings - Fork 25k
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
Wrap jackson exception on malformed json string #114445
Wrap jackson exception on malformed json string #114445
Conversation
Pinging @elastic/es-search-foundations (Team:Search Foundations) |
Thanks for the change @henriquepaes1. Can you please adhere to the formatting style used by the rest of the code? Spaces between braces/parens and catch on same line as braces. It would also be nice to have a test. It could go in |
Pinging @elastic/es-core-infra (Team:Core/Infra) |
Hey @rjernst! Thanks for pointing these out! I'm struggling with the test. Should I write the test for the JsonXContent class or for the AbstractQueryBuilder, where the exception was observed in the issue? Also, should I squash the commits when I finish? |
You could add the test to BaseXContentTestCase, which will be run for all xcontent types.
Don't squash. I suggest you read https://github.com/elastic/elasticsearch/blob/main/CONTRIBUTING.md. |
Hey @rjernst! Are there any other things that I should correct in this PR? |
@elasticsearchmachine ok to test |
@elasticmachine test this please |
@elasticsearchmachine update branch |
@elasticmachine update branch |
@elasticmachine test this please |
@henriquepaes1 at first glance, it looks like a failure unrelated to your change, so I've merged |
@elasticmachine test this please |
Sure @prdoyle! Thanks for the heads up. Let me know if I need to fix something :) |
...-content/impl/src/main/java/org/elasticsearch/xcontent/provider/json/JsonXContentParser.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Patrick Doyle <810052+prdoyle@users.noreply.github.com>
@rjernst - FWIW that linked document says this:
To be clear @henriquepaes1 - we'll do it for you. 😄 |
@henriquepaes1 - I'd like to check with Ryan one more time before proceeding to merge this. That means it will have to wait till next week. |
No problems! Thanks for the clarification and for the help in getting this PR going :) |
@elasticmachine test this please |
@elasticmachine update branch |
@elasticmachine update branch |
@elasticmachine test this please |
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.
Thanks @henriquepaes1 , LGTM
This commit hides the underlying Jackson parse exception when encountered while parsing string tokens.
💚 Backport successful
|
🎉🎉🎉 @henriquepaes1 🎉🎉🎉 🎉🎉🎉 Thank you!!!!! 🎉🎉🎉 |
Thanks for the guidance @benwtrent @rjernst! I'm really glad to contribute, hopefully it was the first of many! |
This PR closes #114142, which observed a 500 response when sending a malformed query to the _search endpoint. I identified that the problem was due to an unchecked exception thrown by the Jackson JSON library when using the .getText( ) method. The solution was to catch the JsonParseException and throw an IllegalArgumentException that gives better information on where the error happened. Now the response looks like the image below: