Skip to content

feat: expose HTTP status code and headers on SDK error classes#319

Open
corvid-agent wants to merge 3 commits intoa2aproject:mainfrom
corvid-agent:fix/expose-http-status-code-in-errors
Open

feat: expose HTTP status code and headers on SDK error classes#319
corvid-agent wants to merge 3 commits intoa2aproject:mainfrom
corvid-agent:fix/expose-http-status-code-in-errors

Conversation

@corvid-agent
Copy link
Contributor

Summary

  • Adds optional statusCode and headers properties to all A2A SDK error classes (TaskNotFoundError, TaskNotCancelableError, PushNotificationNotSupportedError, UnsupportedOperationError, ContentTypeNotSupportedError, InvalidAgentResponseError, AuthenticatedExtendedCardNotConfiguredError) so that consumers can implement HTTP-aware error handling.
  • Updates the REST transport (RestTransport) to extract HTTP status code and response headers from the Response object and pass them through when constructing error instances via mapToError.
  • Exports the new A2AErrorHttpDetails interface from the client entry point for use by consumers.
  • Adds comprehensive tests covering all error types, verifying that statusCode and headers are correctly populated on errors thrown by the REST transport.

Closes #317

Test plan

  • All 414 existing tests pass (no regressions)
  • New tests verify statusCode is set on TaskNotFoundError (404), TaskNotCancelableError (409), PushNotificationNotSupportedError (400), UnsupportedOperationError (405), ContentTypeNotSupportedError (415), InvalidAgentResponseError (502), and AuthenticatedExtendedCardNotConfiguredError (401)
  • New test verifies that response headers (e.g. Retry-After, X-RateLimit-Remaining) are available on errors for rate-limiting / backoff strategies
  • Backward compatibility verified: constructor changes are additive (second parameter is optional), so existing code including JSON-RPC error subclasses continues to work without modification
  • TypeScript lint passes with no new errors

🤖 Generated with Claude Code

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Feat]: Passthrough http status code in error

1 participant