Skip to content

[Bug]: A2A exceptions lost their structured __repr__ after the client error refactor (#761) #1347

Open

Description

@cchinchilla-dev

What happened?

#683 (for #679) added structured __repr__ methods to the client exception classes. The client error refactor in #761 replaced those classes with the new A2AError-based hierarchy (src/a2a/utils/errors.py, src/a2a/client/errors.py), and the __repr__ methods were not carried over.

Exceptions now fall back to the default Exception.__repr__, which only wraps str() output and loses structured attributes. Since server and client errors share A2AError, this affects both sides:

>>> repr(AgentCardResolutionError('Failed to fetch agent card', status_code=404))
"AgentCardResolutionError('Failed to fetch agent card')"  # Loses status_code

>>> repr(InvalidParamsError('Invalid field', data={'field': 'id'}))
"InvalidParamsError('Invalid field')"  # Loses data

Suggested fix: add __repr__ to A2AError, so every domain and client error inherits it, and override it in AgentCardResolutionError, following the same pattern as #683:

# A2AError
def __repr__(self) -> str:
    return (
        f'{self.__class__.__name__}('
        f'message={self.message!r}, '
        f'data={self.data!r})'
    )

# AgentCardResolutionError
def __repr__(self) -> str:
    return (
        f'{self.__class__.__name__}('
        f'status_code={self.status_code!r}, '
        f'message={self.message!r})'
    )

This does not alter __str__ output, traceback formatting, exception hierarchy or catching behavior.

If dropping __repr__ in #761 was intentional, I may be missing some context. In that case, feel free to close this.

I have a fix ready and I'm opening a PR alongside this issue.

Code of Conduct

  • I agree to follow this project's Code of Conduct
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions