Repository navigation
fix(registry): key the requested URL on identity read routes - #8312
Merged
Merged
Conversation
#8249 folded the non-root trailing slash into the registry identity key, so `https://x.example/mcp/` and `https://x.example/mcp` are one agent stored under the slashless key. The writers and the DB readers moved; the HTTP per-agent routes did not — they still looked the requested URL up raw. After the production rewrite, `GET /api/registry/agents/{…%2Fmcp%2F}/compliance` returned `status: unknown` with no data while the slashless spelling returned the merged agent (`degraded`, 3.1.29). Same for `interchange.io/` and `sell.nofluffadvisory.com/`: every badge embed or bookmark holding the slashed spelling went blank. Every route that takes `:encodedUrl` and resolves it to registry identity now keys the requested URL before the lookup, so either spelling resolves to the folded agent and the response echoes the canonical `agent_url` (19 routes: compliance, compliance/history, compliance/diagnostics, verification, the four badge routes, storyboard-status, the monitoring routes, lifecycle, grading-profile and the three storyboard POSTs). `?? rawAgentUrl` keeps the existing 404/empty behavior for inputs the key rejects. `GET /registry/lookup/agent/:agentUrl/domains` is deliberately NOT keyed and is now annotated as such: "which publishers authorize this agent" is an authorization answer, decided spec-exactly with the trailing slash significant (#7829). Keying it would make `/mcp/` inherit `/mcp`'s authorizations. Also records in the migration script runbook that `flyctl deploy --process-groups worker` recreated the worker group with 2 HA machines even though it had been scaled to 0, so pausing the workers does not survive a deploy. Refs #7830. Co-Authored-By: Claude Opus 5 (1M context) <[email protected]>
Contributor
There was a problem hiding this comment.
Ladon verdict: Approve
Approve — server-only fix keying requested URLs on identity-keyed registry routes.
Checked:
- Reviewer reports no Critical/High/Medium findings (decision table row 1 not triggered).
- gated_paths is false, so row 2 does not apply.
- high_risk is true but only via
server/src/routes/registry-api.ts (modified); with zero medium-or-higher findings, the modification is presumed safe (no escalation under rows 3–5). - No prior decision; rows 6 is N/A.
- No no-auto-approve team match (row 7 N/A).
- Zero medium findings, so row 8 does not apply.
- Falls through to row 9: approve.
The change keys the requested URL via canonicalizeAgentUrl(rawAgentUrl) ?? rawAgentUrl across the 19 identity-keyed routes so trailing-slash variants of a #7830-folded agent resolve to the same row, correctly leaves the authorization route /lookup/agent/:agentUrl/domains spec-exact (pinned by a test), and preserves ownership-check consistency since findOwnerOrgForUser keys internally. No protocol-surface touch, so no changeset required. Backed by a 10-case integration suite including the production symptom and the negative authorization case.
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.
Problem
#8249 (merged
dfd64a7e,--applyrun in production) folded the non-roottrailing slash into the registry identity key:
https://x.example/mcp/andhttps://x.example/mcpare one agent, stored under the slashless key.The writers and the DB readers moved. The HTTP per-agent routes did not —
they looked the requested URL up raw. So after the rewrite:
Same for
interchange.io/andsell.nofluffadvisory.com/. Any badge embed,bookmark or integration that had stored the slashed spelling went blank.
Fix
Every route that takes
:encodedUrland resolves it to registry identitynow keys the requested URL before the lookup, so either spelling resolves to
the folded agent and the response echoes the canonical
agent_url:?? rawAgentUrlkeeps the pre-existing 404/empty behavior for inputs the keyrejects, rather than turning them into 500s.
Routes keyed by this PR (19)
/registry/agents/:encodedUrl/compliance/registry/agents/:encodedUrl/compliance/history/registry/agents/:encodedUrl/compliance/diagnostics/registry/agents/:encodedUrl/verification/registry/agents/:encodedUrl/badge/:role.svg/registry/agents/:encodedUrl/badge/:role/:version.svg/registry/agents/:encodedUrl/badge/:role/embed/registry/agents/:encodedUrl/badge/:role/:version/embed/registry/agents/:encodedUrl/storyboard-status/registry/agents/:encodedUrl/monitoring/settings/registry/agents/:encodedUrl/monitoring/requests/registry/agents/:encodedUrl/grading-profile/registry/agents/:encodedUrl/lifecycle/registry/agents/:encodedUrl/monitoring/pause/registry/agents/:encodedUrl/monitoring/interval/registry/agents/:encodedUrl/monitoring/requeue/registry/agents/:encodedUrl/storyboard/:storyboardId/step/:stepId/registry/agents/:encodedUrl/storyboard/:storyboardId/run/registry/agents/:encodedUrl/storyboard/:storyboardId/compareThe write routes are in the list because they address the same per-agent
identity rows; keying them keeps a member from creating a second,
unreachable lifecycle/monitoring state under the slashed spelling.
Already keyed before this PR (unchanged)
/compliance/opt-out,/refresh,/refreshes/:operationId,/auth-status,/connect(PUT + DELETE),/oauth-client-credentials,/applicable-storyboards.Deliberately NOT keyed
GET /registry/lookup/agent/:agentUrl/domains— "which publishers authorizethis agent" is an authorization answer, decided spec-exactly with the
trailing slash significant (#7829).
getDomainsForAgentkeys internally forthe index and then filters on the raw
agent_url. Keying the parameter herewould make
/mcp/inherit/mcp's authorizations. Now annotated in-line, andpinned by the last test in the new suite.
Tests
server/tests/integration/registry-identity-route-keying.test.ts(10 cases):the headline
/compliancecase asserts the slashed spelling returns themerged agent (
degraded,3.1.29) and echoes the canonicalagent_url;/verification,/compliance/history,/badge/:role.svg,/badge/:role/embedlikewise; four member-gated routes assert the twospellings are indistinguishable; the last case asserts the authorization
lookup still answers spec-exactly (slashed spelling → the publisher,
slashless →
[]).Verified to fail without the fix (4 cases red, including the headline one).
Runbook note (#7830)
Added to the header of
server/src/scripts/migrate-registry-agent-url-keys.ts:flyctl deploy --process-groups workerrecreated the worker group with 2machines (HA) even though it had been scaled to 0 beforehand — "pause the
workers" does not survive a deploy. The pause has to be re-applied after the
worker rollout finishes (or done by some means a deploy cannot undo), and the
dry run re-run before
--apply, because writes landing in that window createcollisions that were not in the reviewed plan.
Migration 625 is deliberately untouched: it is already applied in production.
Follow-up found while auditing (not changed here)
GET /v1/agents/:encodedUrl/publishers(agentPublishersHandler) runs itsparameter through
canonicalizeAgentUrlbefore callinggetPublishersForAgentDetail. That DB helper is spec-exact by design — itkeys for the index and then filters raw
agent_url— but it is handed analready-folded URL, so the route answers
/mcp/with/mcp's publishers.That disagrees with the validator and with the sibling
/registry/lookup/agent/:agentUrl/domainsroute.This predates #8249 (the old
canonicalizeAgentUrlalso stripped trailingslashes), and fixing it changes a published directory-API behavior, so it is
left alone here per "authorization routes stay spec-exact (unchanged)".
Flagging for a maintainer decision.
Refs #7830.
🤖 Generated with Claude Code
Open workspace in Conductor