-
Notifications
You must be signed in to change notification settings - Fork 2.3k
[Backport] [2.x] Fixed misunderstanding message 'No OpenSearchException found' when detailed_error disabled #4708
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
Changes from 1 commit
ed4a6de
3125135
b0a62b7
6431cf9
e307f32
461000d
c289c22
702cb9c
626d22c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -594,16 +594,14 @@ public static void generateFailureXContent(XContentBuilder builder, Params param | |||||||
|
|
||||||||
| // Render the exception with a simple message | ||||||||
| if (detailed == false) { | ||||||||
| String message = "No OpenSearchException found"; | ||||||||
| Throwable t = e; | ||||||||
| for (int counter = 0; counter < 10 && t != null; counter++) { | ||||||||
| if (t instanceof OpenSearchException) { | ||||||||
| message = t.getClass().getSimpleName() + "[" + t.getMessage() + "]"; | ||||||||
| break; | ||||||||
| } | ||||||||
| t = t.getCause(); | ||||||||
| } | ||||||||
| builder.field(ERROR, message); | ||||||||
| builder.field(ERROR, ExceptionsHelper.summaryMessage(t)); | ||||||||
|
||||||||
| builder.field(ERROR, ExceptionsHelper.summaryMessage(t)); | |
| builder.field(ERROR, ExceptionsHelper.summaryMessage(e)); |
t is null, which results in a more confusing Internal error exception even when a useful IllegalArgumentException is thrown. e should be passed to summaryMessage so a more useful message is thrown. This already resulted in a reproducible test failure which was fixed in #4702.
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.
@nknize I think the logic behind this code is to find the OpenSearchException down the cause chain (which is t). May be in this case we should do:
builder.field(ERROR, ExceptionsHelper.summaryMessage(t != null ? t : e));
?
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 for reviewing. I will do this fix
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 agree with the suggested change from @reta . The original logic is to find the OpenSearchException down the cause chain, and show its error message.
Looks like if the code is changed to t != null ? t : e here in 2.x branch, then the corresponding change also need to be applied in main branch.
| builder.field(ERROR, ExceptionsHelper.summaryMessage(e)); |
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.
The ExceptionsHelper.summaryMessage(e) version is what exists on main currently. We should probably keep them consistent and then follow up with a change on main to do the ExceptionsHelper.summaryMessage(t != null ? t : e) version (and then backport that PR as well).
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.
@andrross Make sense, thank you! 😄
Uh oh!
There was an error while loading. Please reload this page.
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 @xuezhou25 for the fix.