Repository navigation
refactor(a2a): match ADK errors by type instead of parsing their text - #1548
Merged
Merged
Conversation
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.
Contributor
|
🎉 This PR is included in version 0.226.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Closes #1547.
ADK v0.34.0 returns typed errors from
client.Client(inference-gateway/adk#400):*types.HTTPStatusErrorfor an unexpected status and*types.JSONRPCErrorthat unwraps to a sentinel per spec code. The three text parsers ininternal/protocols/a2a/infrastructure/auth.gonow match by type:unexpected status code ... 401|403regex iserrors.AsonHTTPStatusErrorand a check onStatusCode.(code: -32601)substring match iserrors.Is(err, types.ErrMethodNotFound).errors.AsonHTTPStatusErrorwith 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 typedDatafield does not apply.MethodUnsupportedis unexported, asRejectionis its only caller. Twosubmit_tasktests faked the ADK error as text and now return the typed error the client returns.Out of scope:
isTaskNotFoundErrorinsubmit_task.gostill matches text, because the ADK server reports a missing task as-32603and no sentinel is specific enough yet.Test plan
task precommit:rungo test ./...go test -race ./internal/protocols/a2a/...