YoannAbriel opened a new pull request, #63368:
URL: https://github.com/apache/airflow/pull/63368
## Problem
When `ServerResponseError` is raised and propagates up the call stack
without being explicitly caught and handled, error details are lost. Logs show
only:
```
airflow.sdk.api.client.ServerResponseError: Server returned error
```
...without any information about *what* actually went wrong. This makes
debugging significantly harder, especially for `TaskInstanceOperations` calls
where the exception is not caught and re-logged with `e.detail`.
## Root Cause
`ServerResponseError` stores error details in its `detail` attribute, but
the `__str__()` method (inherited from `httpx.HTTPStatusError`) only returns
the base message. When the exception is logged via traceback or `str(err)`, the
detail is silently dropped.
Some call sites (e.g., `VariableOperations`) explicitly catch
`ServerResponseError` and log `e.detail`, but many others (e.g.,
`TaskInstanceOperations.start()`) let it propagate, losing the detail entirely.
## Fix
Added a `__str__()` override to `ServerResponseError` that appends the
`detail` attribute when present. This ensures error details are always visible
in logs and tracebacks, regardless of how the exception is caught.
**Before:**
```
ServerResponseError: Server returned error
```
**After:**
```
ServerResponseError: Server returned error
Detail: {'reason': 'invalid_state', 'message': 'TI was not in the running
state'}
```
Verified with unit tests. No external service access needed.
Closes: #57961
---
##### Was generative AI tooling used to co-author this PR?
- [X] Yes — Claude Code (Opus 4, claude-opus-4-6)
Generated-by: Claude Code (Opus 4, claude-opus-4-6) following [the
guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#gen-ai-assisted-contributions)
---
* Read the **[Pull Request
Guidelines](https://github.com/apache/airflow/blob/main/contributing-docs/05_pull_requests.rst#pull-request-guidelines)**
for more information.
--
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]