rjgoyln opened a new pull request, #70936:
URL: https://github.com/apache/airflow/pull/70936

   `airflowctl` compared the error response `content-type` against the exact 
string
   `application/json`. Any reverse proxy, ingress, or API gateway that returns
   `application/json; charset=utf-8` — or emits its own 
`application/problem+json`
   error — fell outside that comparison, so `ServerResponseError` was never 
built and
   the friendly "not found" messages in the `dags` and `tasks` commands were 
skipped.
   The bare `httpx.HTTPStatusError` raised instead is not handled by
   `safe_call_command`, so users saw a raw traceback.
   
   Airflow's own API server does not send a charset (Starlette only appends one 
for
   `text/*`), which is why this only surfaces once something sits in front of 
it.
   
   Media types are case-insensitive and may carry parameters (RFC 9110), so the
   header is now parsed instead of compared whole:
   
   | `content-type` | before | after |
   |---|---|---|
   | `application/json` | ✅ friendly | ✅ friendly |
   | `application/json; charset=utf-8` | ❌ traceback | ✅ friendly |
   | `application/json;charset=UTF-8` | ❌ traceback | ✅ friendly |
   | `Application/JSON` | ❌ traceback | ✅ friendly |
   | `application/problem+json` | ❌ traceback | ✅ friendly |
   | `application/jsonp` | `raise_for_status()` | `raise_for_status()` |
   
   Matching more responses also routes two further crash paths into the error
   handler, both fixed here:
   
   - a JSON body that is valid but **not an object** — `dict()` raised 
`ValueError`
     from the same unhandled path
   - a body that does not decode at all — now left to `raise_for_status()`
   
   ### Tests
   
   11 of the added tests fail without the source change. They reuse the existing
   `make_unread_json_response` helper (extended with a `content_type` 
parameter) so
   they exercise the unread/streaming body path rather than an eagerly-loaded 
one.
   
   No newsfragment: `airflow-ctl` release managers regenerate the changelog from
   `git log`.
   
   ---
   
   ##### 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]

Reply via email to