Skip to content

fix(task-sdk): include error details in ServerResponseError string representation#63368

Open
YoannAbriel wants to merge 1 commit intoapache:mainfrom
YoannAbriel:fix/issue-57961
Open

fix(task-sdk): include error details in ServerResponseError string representation#63368
YoannAbriel wants to merge 1 commit intoapache:mainfrom
YoannAbriel:fix/issue-57961

Conversation

@YoannAbriel
Copy link
Contributor

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?
  • Yes — Claude Code (Opus 4, claude-opus-4-6)

Generated-by: Claude Code (Opus 4, claude-opus-4-6) following the guidelines


…presentation

When ServerResponseError propagated up the stack without being
explicitly caught and handled, the error details were lost because
__str__() only returned the base message without the detail attribute.

This made debugging difficult as logs would show 'Server returned error'
without any context about what actually went wrong.

Added __str__() override to include the detail when present, so error
details are always visible in logs and tracebacks regardless of how the
exception is caught and re-raised.

Closes: apache#57961
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.

Error details missing in the logs for internal SDK API calls

1 participant