Skip to content

fix(httpapi): percent-decode the registry {id} on search, refresh, edit and remove - #1774

Merged
Dumbris merged 1 commit into
smart-mcp-proxy:mainfrom
rudycelekli:fix/registry-path-param-decode-20261024-01
Oct 26, 2026
Merged

Dumbris merged 1 commit into
smart-mcp-proxy:mainfrom
rudycelekli:fix/registry-path-param-decode-20261024-01

Conversation

@rudycelekli

Copy link
Copy Markdown
Contributor

Problem

Custom registry ids are user-chosen (registry add-source --id ...) and aren't restricted to a slug, so they can contain characters such as : or /. The CLI builds these URLs with url.PathEscape and the Web UI with encodeURIComponent, so those characters reach the server percent-encoded. chi routes on RawPath, which means chi.URLParam(r, "id") returns the encoded form (acme%3Ainternal) and the exact-match registry lookup misses.

As a result, a registry added as acme:internal can't be searched, refreshed, edited or removed. handleAddFromRegistry already decodes the same param (MCP-1056); the other four handlers don't.

Fix

Wrap {id} in the existing decodePathParam in handleSearchRegistryServers, handleRefreshRegistryCache, handleEditRegistrySource and handleRemoveRegistrySource.

Test

TestRegistryRoutes_DecodeIDParam sends acme%3Ainternal to all four routes and checks the id passed to the controller. On main all four subtests receive acme%3Ainternal; with this change they receive acme:internal. go test -count=1 ./internal/httpapi/ passes.

Made with Cursor

@codecov-commenter

Copy link
Copy Markdown

⚠️ Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

…it and remove

A custom registry id is user-chosen (add-source --id) and may contain
characters the CLI (url.PathEscape) and Web UI (encodeURIComponent)
percent-encode, such as ':' or '/'. chi routes on RawPath, so the {id}
param arrived encoded and the exact-match lookup missed: the registry
could be added but not searched, refreshed, edited or removed.
handleAddFromRegistry already decodes; apply the same decodePathParam
in the other four registry handlers.
@rudycelekli
rudycelekli force-pushed the fix/registry-path-param-decode-20261024-01 branch from dc0728c to 3a908d2 Compare October 24, 2026 22:18

@Dumbris Dumbris left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Verified: the PR test fails on main for the reason described and passes on this branch merged with main; race tests for the touched packages and CI lint (bare and server tags) are clean. Also built and tested together with the rest of this batch, independently reviewed, and cross-reviewed with a second model.

@Dumbris
Dumbris merged commit 2a99e93 into smart-mcp-proxy:main Oct 26, 2026
47 of 48 checks passed
@Dumbris

Dumbris commented Oct 26, 2026

Copy link
Copy Markdown
Member

Merged. Thank you, @rudycelekli! Custom registries with ids like acme:internal can be searched, refreshed, edited and removed.

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.

3 participants