refactor(a2a)!: converge a2a_agent auth_type to the control-plane enum (drop oauth2) - #755
Merged
Merged
Conversation
…m (drop oauth2) The a2a_agent resource accepted auth_type oauth2 (plus oauth-only client_id / token_url / scopes fields) at the schema layer, but the runtime never implemented it — an oauth2-configured agent always answered 501 at request time — and the control plane's canonical resource model allows only none / bearer / api_key for A2A agents. Converge to the spec (see CLAUDE.md: The Resource Model Is Canonical in cp-admin.yaml): remove the oauth2 enum arm and the three oauth-only fields, make upstream_from_a2a_agent infallible, drop the unreachable Unsupported -> 501 mapping, and regenerate the resource schema. The mcp_server oauth2 auth is part of the control-plane spec and fully implemented in the runtime — untouched. BREAKING CHANGE: stored a2a_agent documents carrying auth_type oauth2 (only creatable via the standalone Admin API, and always 501 at request time) now fail schema validation: the snapshot loader skips them with a warning and surfaces them as rejected entries, and the Admin API rejects such payloads with 400.
📝 WalkthroughWalkthroughA2A OAuth2 configuration is removed from models and schemas. Admin validation rejects OAuth2 payloads through schema validation, while upstream construction and proxy handlers use a direct non-error-returning path for the remaining authentication modes. ChangesA2A OAuth2 removal
Estimated code review effort: 4 (Complex) | ~45 minutes Sequence Diagram(s)sequenceDiagram
participant A2ARequest
participant Proxy
participant Bridge
participant A2aUpstream
A2ARequest->>Proxy: send agent request
Proxy->>Bridge: build upstream from A2aAgent
Bridge->>A2aUpstream: return auth mapping and timeout
Proxy->>A2aUpstream: forward request
Possibly related PRs
🚥 Pre-merge checks | ✅ 5 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
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.
What
Converge the
a2a_agentresource'sauth_typeto the control-plane resource model, per the repo rule "The Resource Model Is Canonical in cp-admin.yaml" (CLAUDE.md): the control-plane spec allows onlynone/bearer/api_keyfor A2A agents and defines no OAuth fields on this resource.The
oauth2arm here was schema-only forward compatibility: the runtime never implemented it, so an agent configured withauth_type: oauth2always answered501 Not Implementedat request time, and the control plane never accepted such a document in the first place. After this change, schema == spec == runtime reality.(The
mcp_serverresource'soauth2auth is a different story — it is part of the control-plane spec and fully implemented in the runtime. It is deliberately untouched.)Changes
crates/aisix-core/src/models/a2a_agent.rs— remove theA2aAuthType::OAuth2variant and the oauth2-exclusiveclient_id/token_url/scopesfields (none of which exist on the control-plane a2a_agent resource, and none of which were read by thebearer/api_keypaths); update thesecretdoc comment accordingly.crates/aisix-core/src/models/schema.rs— drop theoauth2title entry from the generatedA2aAuthTypeschema.crates/aisix-a2a/src/bridge.rs—upstream_from_a2a_agentis now infallible (every representableauth_typemaps to a working upstream auth); remove the forward-compat doc note.crates/aisix-a2a/src/error.rs— remove the now-unconstructableA2aError::Unsupportedvariant.crates/aisix-proxy/src/a2a.rs— delete the unreachable501branches in the/a2a/:agentdispatch and agent-card handlers and theUnsupported → 501status mapping.crates/aisix-admin/src/a2a_agents_handlers.rs— delete the oauth2 credential-coupling check; anoauth2payload now fails schema validation up front.schemas/resources/a2a_agent.schema.json— regenerated (cargo run -p aisix-core --bin dump-schema).Test coverage was converted, not deleted:
oauth2acceptance test → rejection test (auth_type: "oauth2"and each former OAuth field now fail deserialization), plus anapi_keyround-trip test replacing the oauth2 round-trip.oauth2auth_type → 400 schema rejection".Connect/Request→502assertions.No case under
tests/e2e/references the/a2asurface, so there was no oauth2 e2e pin to convert.Compatibility note (breaking)
Stored
a2a_agentdocuments carryingauth_type: oauth2— only creatable through the standalone Admin API, and always501at request time — no longer validate: the snapshot loader skips them with a warning and surfaces them as rejected entries, and the Admin API rejects such payloads with400(previously accepted-then-501). Documents usingnone/bearer/api_keyare unaffected; no field they use changed.Verification
cargo fmt --all -- --check— cleancargo clippy --workspace --all-targets -- -D warnings— cleancargo test -p aisix-core -p aisix-a2a -p aisix-admin -p aisix-proxy— 1126 passed, 0 failed, 2 ignored (pre-existing)cargo run -p aisix-core --bin dump-schema— onlyschemas/resources/a2a_agent.schema.jsonchanged (drift gate will agree)cargo run -p aisix-admin --bin dump-openapi— succeeds; in the dumped spec theA2aAgent/A2aAgentEntry/A2aAuthTypecomponents carry nooauth2/client_id/token_url/scopesremnant, whileMcpServerstill documents its (implemented)oauth2cargo build --bin aisix— succeedsSummary by CodeRabbit
Breaking Changes
Bug Fixes
Standalone operators, two additional notes: a previously stored
auth_type: oauth2agent document is skipped by the loader after this change (WARN logschema validation failed; skippingplus theschema_rejectedcounter); find such documents via that log line and delete or fix them —DELETE /admin/v1/a2a_agents/{id}works without decoding the document. Calls to such an agent's/a2a/<name>path change from501to404, because the resource is absent from the snapshot.