Repository navigation
Description
Summary
Four low-severity defects found by an /edge-cases sweep of the #736 A2A outbound path. Grouped into one issue because they are all low, all fail-closed (each produces a refusal or a no-op, never a wrong-destination call or a leaked credential), and all live in the same feature — four separate P3s would be backlog noise.
Each is pinned by a strict-xfail in tests/unit/test_736_a2a_outbound_edges.py, so whichever ones get fixed will turn that marker red and force it to be retired.
F1 — _same_origin does not normalise IPv6 literals, contrary to its docstring
src/backend/services/a2a_client.py::_same_origin documents "IPv6 bracket forms compared after normalisation". It does not: it compares urlsplit().hostname textually, and canonical_host leaves an IPv6 literal untouched (idna rejects it, the ASCII fallback passes it through).
So a registered IPv6-literal endpoint whose peer card declares the same address in expanded form is refused card_origin_mismatch:
registered: https://[2606:4700:4700::1111]/a2a
card url: https://[2606:4700:4700:0:0:0:0:1111]/a2a -> card_origin_mismatch
An IPv6-literal endpoint is registrable (it passes validate_a2a_endpoint_url), so this is reachable. Fail-closed, and the docstring is the part that is wrong.
Test: test_E6_ipv6_literal_origins_compare_equal_across_spellings
F2 — port :0 means three different things in one call path
_validate_public_https_urlcoalesces it to 443 (parsed.port or 443—0is falsy), and resolves on 443_pinned_urldrops it, so the connection also goes to 443_same_origincompares it literally as port 0
A :0 endpoint therefore validates, would connect correctly, and is then permanently refused card_origin_mismatch against any card declaring the ordinary form — with an error that blames the peer for something the registration did. This is the §null/optional conflation: 0, None and "absent" are three different values and two of the three helpers fold them together differently.
Test: test_D7_a_zero_port_is_normalised_consistently_across_the_call_path
F3 — refusal reason codes are derived by substring-matching the human message
validate_a2a_endpoint_url maps ValueError → A2AEndpointUrlError.reason with if "must use HTTPS" in message / "internal address" in message / "could not be resolved" in message.
This is the exact fragility A2AEndpointUrlError's own docstring warns against — "string-matching a human message is how those two drift apart" — happening in the function that raises it.
It is reachable because the DNS-failure message interpolates the hostname and canonical_host's ASCII fallback passes hosts containing spaces:
https://an internal address.example/a2a (DNS fails)
-> reason=endpoint_private_address (should be endpoint_dns_failure)
The router maps both to 400, so the HTTP status is unaffected and there is no bypass. What breaks is the machine-readable reason the MCP tool branches on, plus an operator being told the host resolves to an internal address when it does not resolve at all.
Test: test_D12_a_dns_failure_is_never_misreported_as_a_private_address
F5b — a whitespace-only credential silently clears the stored one
upsert_endpoint skips the header-safety check on a blank credential (if credential.strip() and ...) but then takes the elif credential: branch, because " " is truthy, and writes "".
So None and "" preserve the stored secret; " " destroys it — a fourth path through a model the docstring describes as three (omit / set / clear_credential). Not reachable over HTTP: A2AOutboundEndpointUpsert._validate_credential normalises a blank SecretStr to None, so the API surface is honest. This is a public-module-function defect.
Test: test_G4_a_whitespace_only_credential_does_not_silently_clear_the_stored_one
Acceptance Criteria
- F1:
_same_originnormalises IPv6 literals before comparing (or its docstring is corrected to state that it does not, and the limitation is recorded) - F2: the three helpers agree on
:0— either all treat it as the scheme default, or registration refuses it by name - F3:
validate_a2a_endpoint_urlderives itsreasonfrom structured state rather than by substring-matching prose (e.g. the inner helper raises a reason-carrying error directly) - F5b:
upsert_endpointtreats a whitespace-only credential the same asNone/""(leave unchanged);clear_credentialremains the only removal path - Each fixed defect has its strict-
xfailmarker retired intests/unit/test_736_a2a_outbound_edges.pyand the test passes plainly - Partial fixes are fine — the markers are independent, so this issue can be closed incrementally
Technical Notes
F1 and F2 are both in _same_origin, which is the card same-origin pin — the single control that stops a hostile agent card from redirecting a credentialed POST. Both current behaviours are conservative (refuse), so neither weakens that control; they make legitimate endpoints unusable rather than illegitimate ones reachable. Any fix must keep the refuse-on-unparseable property: _same_origin returns False for junk input on both sides, including junk-vs-identical-junk, and that is load-bearing.
F3's fix should be structural rather than a better set of substrings — the reason codes already exist as A2A_URL_REASONS; the inner _validate_public_https_url just doesn't carry them. Note the same sweep added a parity guard (test_H1_the_status_map_has_no_dead_entries) that fails if a reason is renamed at the raise site while the router's status map keeps the old spelling, so a refactor here is covered.
Activity
dolho commentedon Aug 14, 2026
/claim — picking up the remaining item.
F1/F2/F3 are already handled, each filed on the enterprise tracker and fixed in an open stack:
:0) → ent#398 → PR fix(a2a): one port normalisation for validation, pinning and origin comparison (ent#398) #2180F5b (whitespace-only credential) is the one left — branch
fix/2175-blank-credential-preserves-secret.github-actions commentedon Aug 14, 2026
@dolho This issue is already assigned to dolho. Use
/unclaimfirst if you want to take over.dolho commentedon Aug 14, 2026
F5b: #2183 (targets
dev).All four findings now have a fix in flight:
:0Each was verified against a real instance, not just unit-tested: F2 and F1 through genuine TLS A2A calls to a lab peer (dev refuses
:0and compressed-IPv6 endpointscard_origin_mismatch; the branches complete them), F3 and F5b through the real code paths against the live database.The one AC none of them could satisfy: every finding's
xfaillives intests/unit/test_736_a2a_outbound_edges.py, which is not ondev— it arrives with PR #2178, still open. Five pins there (G7, D7, E6, D12, G4) are now fixed and will XPASS-strict when it rebases. Each PR carries an equivalent test ondevso no property is unpinned meanwhile, and I have offered on #2178 to do the rebase + un-xfail pass.Also worth noting for whoever closes this: #2177 (the sibling F4 delete fix, already merged) added a create-time guard that refuses a new endpoint named after an existing id — which is how G7's setup builds its collision, so that test needs either a direct-write setup or the guard dropped. Details on #2178.
fix(a2a): a blank credential leaves the stored secret alone, in every…
fix(a2a): a blank credential leaves the stored secret alone, in every…