Skip to content

refactor(a2a): match ADK errors by type instead of parsing their text - #1548

Merged
edenreich merged 1 commit into
mainfrom
refactor/a2a-typed-errors
Oct 6, 2026
Merged

edenreich merged 1 commit into
mainfrom
refactor/a2a-typed-errors

Conversation

@edenreich

Copy link
Copy Markdown
Contributor

Summary

Closes #1547.

ADK v0.34.0 returns typed errors from client.Client (inference-gateway/adk#400): *types.HTTPStatusError for an unexpected status and *types.JSONRPCError that unwraps to a sentinel per spec code. The three text parsers in internal/protocols/a2a/infrastructure/auth.go now match by type:

  • The unexpected status code ... 401|403 regex is errors.As on HTTPStatusError and a check on StatusCode.
  • The (code: -32601) substring match is errors.Is(err, types.ErrMethodNotFound).
  • The guardrail refusal regex is errors.As on HTTPStatusError with a 403. Its message is still read from the body as JSON: a refusal is a 403 whose body is a JSON-RPC envelope, not a JSON-RPC error object, so the typed Data field does not apply.

MethodUnsupported is unexported, as Rejection is its only caller. Two submit_task tests faked the ADK error as text and now return the typed error the client returns.

Out of scope: isTaskNotFoundError in submit_task.go still matches text, because the ADK server reports a missing task as -32603 and no sentinel is specific enough yet.

Test plan

  • task precommit:run
  • go test ./...
  • go test -race ./internal/protocols/a2a/...

ADK v0.34.0 returns *types.HTTPStatusError for an unexpected status and a
*types.JSONRPCError that unwraps to a sentinel per spec code. The 401/403
regex, the guardrail envelope regex and the (code: -32601) substring match
in auth.go become errors.As and errors.Is. A guardrail refusal is a 403 with
a JSON-RPC body, not a JSON-RPC error object, so its message is still read
from the status error's body. The two submit_task tests that faked the ADK
error as text now return the typed error the client returns.
@edenreich
edenreich requested a review from a team as a code owner October 6, 2026 15:29
@edenreich
edenreich merged commit 991a727 into main Oct 6, 2026
13 checks passed
@edenreich
edenreich deleted the refactor/a2a-typed-errors branch October 6, 2026 16:13
@inference-gateway-releaser

Copy link
Copy Markdown
Contributor

🎉 This PR is included in version 0.226.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

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

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

[TASK] Refactor A2A error parsing onto the ADK typed errors

1 participant