Skip to content

Keep API error details when a response declares a JSON charset - #71196

Closed
rjgoyln wants to merge 1 commit into
apache:mainfrom
rjgoyln:parse-json-media-type-in-api-client-errors
Closed

Keep API error details when a response declares a JSON charset#71196
rjgoyln wants to merge 1 commit into
apache:mainfrom
rjgoyln:parse-json-media-type-in-api-client-errors

Conversation

@rjgoyln

@rjgoyln rjgoyln commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

Both API clients treated a response as a parseable error only when Content-Type was exactly application/json, so any media type carrying parameters — application/json; charset=utf-8, as proxies and gateways routinely emit on the errors they generate themselves — skipped error parsing and fell through to raise_for_status(). That loses the server's detail, and it raises a plain httpx.HTTPStatusError, so the except ServerResponseError branches in the supervisor and in the CLI commands stop matching.

Airflow's own API server is unaffected — Starlette appends a charset only to text/* responses — so this surfaces only where something between client and API server rewrites the header. Parameters are now stripped and the media type case folded; application/problem+json remains unaccepted.


Was generative AI tooling used to co-author this PR?
  • Yes — Claude Code (Opus 5)

Generated-by: Claude Code (Opus 5) following the guidelines

The Task SDK and airflow-ctl clients only parsed a server error body when
the response Content-Type was exactly "application/json", so a media type
carrying parameters — "application/json; charset=utf-8" from a proxy or
gateway, for instance — fell through to raise_for_status(). Callers then
lost the server's error detail and, because the raised exception was no
longer a ServerResponseError, the status-specific handling in the
supervisor and in the CLI commands stopped matching.
@rjgoyln

rjgoyln commented Aug 5, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favour of #70936, which already covers the airflow-ctl side of this. The Task SDK client has the same exact-string content-type comparison, so it is folded into that PR instead of being fixed separately here.


Drafted-by: Claude Code (Opus 5) (no human review before posting)

@rjgoyln rjgoyln closed this Aug 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant