-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
Fix: avoid further dispatch when ThreadContext population fails #121665
Fix: avoid further dispatch when ThreadContext population fails #121665
Conversation
Pinging @elastic/es-core-infra (Team:Core/Infra) |
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.
LGTM
Slightly odd tests, kind of unrelated to the bug in question, tho it's not easy to see how else to test for this bug.
I agree they are kind of unrelated: the case (in)sensitiveness tests came first, just to "prove" (for an unrelated issue) that ES was behaving correctly. They just highlighted the error, as they failed but not where I expected. |
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.
lgtm, thanks for adding those tests @ldematte 🧸
While adding some tests to assert that ES handling of multiple headers is in line with the specs (headers are treated in a case-insensitive way - see #116139), we discovered a problem introduced with #95040.
If the header validation fails while we populate the ThreadContext, an error answer is sent, but we also proceed with the normal dispatch. This causes an error downstream: as soon as we try to read the request body, an assertion is hit, as the request has already been closed and marked as completed.
This PR fixes the issue by making the 2 paths mutually exclusive.