Skip to content

fix(registry): key the requested URL on identity read routes - #8312

Merged
bokelley merged 1 commit into
mainfrom
fix/7830-identity-read-routes-key-input
Oct 18, 2026
Merged

bokelley merged 1 commit into
mainfrom
fix/7830-identity-read-routes-key-input

Conversation

@bokelley

@bokelley bokelley commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

Problem

#8249 (merged dfd64a7e, --apply run in production) folded the non-root
trailing slash into the registry identity key: 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 looked the requested URL up raw. So after the rewrite:

GET /api/registry/agents/https%3A%2F%2Fadcp.teqblaze.io%2Fmcp%2F/compliance
  → { status: "unknown" }            # no data
GET /api/registry/agents/https%3A%2F%2Fadcp.teqblaze.io%2Fmcp/compliance
  → { status: "degraded", adcp_version: "3.1.29", ... }

Same for interchange.io/ and sell.nofluffadvisory.com/. Any badge embed,
bookmark or integration that had stored the slashed spelling went blank.

Fix

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:

const rawAgentUrl = decodeURIComponent(req.params.encodedUrl);
if (!validateAgentUrlParam(rawAgentUrl)) {
  return res.status(400).json({ error: "Invalid agent URL" });
}
// Identity-keyed route: key the requested URL so either spelling of a folded
// agent resolves to the same row, and the response echoes the
// canonical form (#7830). Authorization routes stay spec-exact.
const agentUrl = canonicalizeAgentUrl(rawAgentUrl) ?? rawAgentUrl;

?? rawAgentUrl keeps the pre-existing 404/empty behavior for inputs the key
rejects, rather than turning them into 500s.

Routes keyed by this PR (19)

Route Method
/registry/agents/:encodedUrl/compliance GET
/registry/agents/:encodedUrl/compliance/history GET
/registry/agents/:encodedUrl/compliance/diagnostics GET
/registry/agents/:encodedUrl/verification GET
/registry/agents/:encodedUrl/badge/:role.svg GET
/registry/agents/:encodedUrl/badge/:role/:version.svg GET
/registry/agents/:encodedUrl/badge/:role/embed GET
/registry/agents/:encodedUrl/badge/:role/:version/embed GET
/registry/agents/:encodedUrl/storyboard-status GET
/registry/agents/:encodedUrl/monitoring/settings GET
/registry/agents/:encodedUrl/monitoring/requests GET
/registry/agents/:encodedUrl/grading-profile PUT
/registry/agents/:encodedUrl/lifecycle PUT
/registry/agents/:encodedUrl/monitoring/pause PUT
/registry/agents/:encodedUrl/monitoring/interval PUT
/registry/agents/:encodedUrl/monitoring/requeue POST
/registry/agents/:encodedUrl/storyboard/:storyboardId/step/:stepId POST
/registry/agents/:encodedUrl/storyboard/:storyboardId/run POST
/registry/agents/:encodedUrl/storyboard/:storyboardId/compare POST

The 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 authorize
this agent" is an authorization answer, decided spec-exactly with the
trailing slash significant (#7829). getDomainsForAgent keys internally for
the index and then filters on the raw agent_url. Keying the parameter here
would make /mcp/ inherit /mcp's authorizations. Now annotated in-line, and
pinned by the last test in the new suite.

Tests

server/tests/integration/registry-identity-route-keying.test.ts (10 cases):
the headline /compliance case asserts the slashed spelling returns the
merged agent (degraded, 3.1.29) and echoes the canonical agent_url;
/verification, /compliance/history, /badge/:role.svg,
/badge/:role/embed likewise; four member-gated routes assert the two
spellings 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 worker recreated the worker group with 2
machines (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 create
collisions 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 its
parameter through canonicalizeAgentUrl before calling
getPublishersForAgentDetail. That DB helper is spec-exact by design — it
keys for the index and then filters raw agent_url — but it is handed an
already-folded URL, so the route answers /mcp/ with /mcp's publishers.
That disagrees with the validator and with the sibling
/registry/lookup/agent/:agentUrl/domains route.

This predates #8249 (the old canonicalizeAgentUrl also stripped trailing
slashes), 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

#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]>

@aao-secretariat aao-secretariat Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant