Eason09053360 opened a new pull request, #73307: URL: https://github.com/apache/airflow/pull/73307
## Why `safe_call_command` in `airflow-ctl/src/airflowctl/ctl/cli_config.py` is the single place where an airflowctl failure becomes one actionable line instead of a traceback. It caught `ServerResponseError`, but the API client only builds that for a 4xx/5xx response whose body is JSON (`ServerResponseError.from_response`). For anything else the response hook falls through to `response.raise_for_status()`, which raises the bare `httpx.HTTPStatusError` that `ServerResponseError` subclasses — and a parent class is not caught by a child's `except`, so nothing handled it. Two shapes of response land there, and both are cases where the operator has the least context to work with: - a 3xx, e.g. an SSO proxy in front of the API server answering with a redirect (the client does not follow redirects); - a 4xx/5xx whose body is not JSON, e.g. an ingress returning its own HTML error page. Neither ever reached the Airflow API server, and a traceback says nothing about that. Related: #72468 closes the same kind of gap on the other side of this function, for airflowctl's own exception family. ## What Adds an `except httpx.HTTPStatusError` clause to `safe_call_command`, printing the httpx message (which already names the status, the URL, and for a redirect its `Location`) and exiting 1 — the same exit code the uncaught traceback produced, so scripted callers are unaffected. A redirect additionally gets one line pointing at the configured API URL, since a 3xx does not read as an error the way a 502 does. The clause has to sit below `except ServerResponseError`, or that branch becomes unreachable; the comment in the diff records why. Tests in `airflow-ctl/tests/airflow_ctl/ctl/test_cli_config.py` cover a redirect and a non-JSON 4xx and 5xx, raising through a real `response.raise_for_status()` rather than a hand-built exception, and assert both that the redirect hint appears and that it does not appear for the other two. --- ##### Was generative AI tooling used to co-author this PR? - [X] Yes — Claude Code (Opus 5) Generated-by: Claude Code (Opus 5) following [the guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions) -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
