fix(druid): handle 429/503 HTML before JSON parse in DirectDruidClient - #20151
Open
shoemoney wants to merge 1 commit into
Open
fix(druid): handle 429/503 HTML before JSON parse in DirectDruidClient#20151shoemoney wants to merge 1 commit into
shoemoney wants to merge 1 commit into
Conversation
Fix verified RED->GREEN. Broker masks 429/503 HTML as JsonParseException 0x3c at DirectDruidClient.java:242
| break; | ||
| } | ||
| } | ||
| if (statusCode == 429 || statusCode == 503) { |
Member
There was a problem hiding this comment.
this if block should be placed in front of above if block which detects whether the response is html body
| } | ||
| throw QueryCapacityExceededException.withErrorMessageAndResolvedHost(msg); | ||
| } | ||
| if (isHtmlContentType || isHtmlBody) { |
Member
There was a problem hiding this comment.
I think we should re-organise the new code into two methods which follow current checkTotalBytesLimit and checkQueryTimeout, so in this handleResponse it looks like sth like:
...
checkQueryTimeout();
checkStatusCode(); // which checks 429 and 503
checkHtmlResponse();
checkTotalBytesLimit(response.getContent().readableBytes());
...
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Broker can return HTTP 429 or 503 with an HTML error page (for example from a load balancer or reverse proxy) instead of the expected JSON. DirectDruidClient at 242 enqueues the raw body and later JsonParserIterator tries to parse it as JSON, which fails with a JsonParseException for 0x3c ('<') and masks the real capacity error.
Fix checks response status and Content-Type before enqueue in handleResponse:
This preserves the correct exception type for capacity errors and avoids HTML being misreported as a JSON parse failure.
Testing
Release note
Fix broker HTML 429/503 responses being masked as JsonParseException in DirectDruidClient.
Key changed/added classes in this PR
This PR has: