Skip to content

fix: handle unstructured upstream query error responses#19427

Open
mike-lmctl wants to merge 1 commit intoapache:masterfrom
mike-lmctl:fix-unstructured-query-error-response
Open

fix: handle unstructured upstream query error responses#19427
mike-lmctl wants to merge 1 commit intoapache:masterfrom
mike-lmctl:fix-unstructured-query-error-response

Conversation

@mike-lmctl
Copy link
Copy Markdown

Fixes #19407.

Description

This updates DirectDruidClient so HTTP error responses with unstructured bodies, such as Jetty HTML 429/503 pages, are converted into Druid query exceptions before the response stream reaches the JSON parser.

Structured JSON/Smile error responses still use the existing parsing path. For unstructured 429/503 responses, the client now reports a query capacity error since those statuses indicate upstream rate limiting or overload. If Content-Type is missing, the response body is sniffed so JSON-looking error bodies still take the existing path.

Release note

Broker query failures caused by upstream 429/503 HTML error responses now surface as query capacity errors instead of raw JSON parse errors.


Key changed/added classes in this PR
  • DirectDruidClient
  • DirectDruidClientTest

This PR has:

  • been self-reviewed.
  • a release note entry in the PR description.
  • added comments explaining the "why" and the intent of the code wherever would not be obvious for an unfamiliar reader.
  • added unit tests or modified existing tests to cover new code paths, ensuring the threshold for code coverage is met.

Tested with:

mvn -pl server -am -Dtest=DirectDruidClientTest -Dsurefire.failIfNoSpecifiedTests=false test -DskipITs

Result: 13 tests passed.

Upstream overload and proxy error paths can return HTML bodies for HTTP error
statuses. Convert those unstructured error bodies into query exceptions before
the JSON parser sees the stream, while keeping structured JSON and Smile error
responses on the existing path.

Tested: mvn -pl server -am -Dtest=DirectDruidClientTest -Dsurefire.failIfNoSpecifiedTests=false test -DskipITs
@mike-lmctl mike-lmctl changed the title Handle unstructured upstream query error responses fix: handle unstructured upstream query error responses May 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Broker fails query with JsonParseException: Invalid type marker byte 0x3c when Historical/Broker returns Jetty's HTML error page for HTTP 429 / 503

1 participant