Fix airflowctl traceback when a proxy returns a non-JSON error - #71424
Closed
rjgoyln wants to merge 1 commit into
Closed
Fix airflowctl traceback when a proxy returns a non-JSON error#71424rjgoyln wants to merge 1 commit into
rjgoyln wants to merge 1 commit into
Conversation
Only a JSON error body is turned into a ServerResponseError, so an error page from a reverse proxy or gateway sitting in front of the API server reached the user as an unhandled exception with no indication of where the response actually came from.
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.
Summary
safe_call_commandcatchesServerResponseErrorbut not thehttpx.HTTPStatusErrorit inherits from, and only a JSON error body ever becomes aServerResponseError. Every other error response therefore escapes as an unhandled exception, and the user gets a traceback where a message belongs.Those responses come from whatever sits in front of the API server rather than from Airflow — a reverse proxy returning its own
text/html502 during a restart, or an SSO gateway answering with a login page. Since the traceback names httpx, it reads as a client bug. The command now exits 1 with the status and the response's content type, enough to place the blame correctly.Independent of #70936, which widens the media-type check in the API client.
Was generative AI tooling used to co-author this PR?
Generated-by: Claude Code (Opus 5) following the guidelines