fix(server): register /.well-known/agent.json alias route in create_a2a_server#613
Merged
fix(server): register /.well-known/agent.json alias route in create_a2a_server#613
Conversation
…2a_server The 0.3 discovery alias was exempted from auth (auth.py _A2A_DISCOVERY_PATHS) but never registered as a Starlette route, causing buyer SDKs that probe the alias (including @adcp/sdk CLI auto-detection) to receive 404/503. Adds a second create_agent_card_routes call with card_url="/.well-known/agent.json" so both paths serve identical agent-card JSON without a redirect round-trip. Also tightens three tests that masked the bug by accepting 404 as valid, fixes the misleading auth comment, adds an inverse coverage check asserting all _A2A_DISCOVERY_PATHS entries are registered routes, and corrects the docs path. Closes #612 https://claude.ai/code/session_01JHq6DLPhFf2kQQpUkPtfZe
- Remove brand name from inline comment (use generic "A2A 0.3 buyer SDKs") - Expand A2ABearerAuthMiddleware docstring to mention 0.3 alias path - Add comment to inverse-drift-guard test noting it's structural-only https://claude.ai/code/session_01JHq6DLPhFf2kQQpUkPtfZe
Contributor
Author
Pre-merge expert pass (fresh independent review)
Admin-merging. |
Contributor
Author
|
Acknowledged — thanks for the independent expert pass and the forward-looking caveat on the Triaged by Claude Code. Session: https://claude.ai/code/session_01TJqAJYiwTZoGQVdL1cEpDP Generated by Claude Code |
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.
Closes #612
Summary
create_agent_card_routes()(a2a-sdk) registers exactly one route:/.well-known/agent-card.json. The 0.3 discovery alias/.well-known/agent.jsonwas already present in_A2A_DISCOVERY_PATHS(auth middleware exempted it) but was never registered as a Starlette route — returning 404 or 503 at edge proxies. This broke@adcp/sdkCLI auto-detection of A2A transport, which probes the alias as a positive A2A signal.Fix: Call
create_agent_card_routes(agent_card=agent_card, card_url="/.well-known/agent.json")a second time increate_a2a_server(). Both paths serve identical agent-card JSON using independent handler closures — no redirect round-trip, no shared mutable state.Also fixed:
test_unified_mcp_a2a.py) or asserting only the canonical path (test_a2a_server.py)test_all_discovery_paths_are_registered_routes) asserting every path in_A2A_DISCOVERY_PATHShas a live Starlette route — this is the structural check that would have caught issue A2A: /.well-known/agent.json (0.3 alias) returns 404 — route not registered, breaking SDK auto-detection #612 at the point/.well-known/agent.jsonwas added to the frozensetauth.py("retained by enable_v0_3_compat=True") corrected to note the route is registered explicitly increate_a2a_serverA2ABearerAuthMiddlewaredocstring updated to mention both exempted pathsdocs/handler-authoring.mdcorrected to name the canonical path (/.well-known/agent-card.json) with a parenthetical noting the 0.3 aliasNits (not fixed in this PR):
test_a2a_server.py:349usesstartswith("/.well-known/agent-card")— could useAGENT_CARD_WELL_KNOWN_PATHconstant for exactnessWhat was tested
Pre-PR review
create_agent_card_routescreates fresh independent closures per call; no shared state). Two issues addressed (auth docstring, test limitation comment). Noted thattest_unified_mcp_a2a.pytightening fromin (200, 404)→== 200is the right move./.well-known/agent.jsonis confirmed as the intended 0.3 alias (already in_A2A_DISCOVERY_PATHSwith intentional auth exemption). No canonicalization concern (neither well-known path appears in the serialized card body). Absence ofLink: rel=canonicalon alias response is consistent with all other A2A implementations and not required by the spec.Session: https://claude.ai/code/session_01JHq6DLPhFf2kQQpUkPtfZe
Generated by Claude Code