fix(agents): URL-decode collection/agent name path params (#10443)#10471
Merged
Conversation
Collection and agent names carry a "legacy-api-key:" prefix, so the ':'
arrives percent-encoded as %3A in the request path. Echo routes such
paths via URL.RawPath and stores the matched path-param value still
escaped, so c.Param("name") returned "legacy-api-key%3ALiteraryResearch"
and the store lookup 404'd ("collection not found").
This was second-order fallout of #10375/#10387: once colons became valid
in names, the URL-decode gap surfaced on every name-bearing endpoint.
Add a decodedParam helper that url.PathUnescape's the param (falling back
to the raw value on invalid encoding) and wire it into all collection
endpoints and the agent :name endpoints, which share the identical
prefix. The entry endpoints already unescaped c.Param("*"); this closes
the same gap for :name.
Fixes #10443
Signed-off-by: Ettore Di Giacinto <mudler@localai.io>
Assisted-by: Claude:claude-opus-4-8 [Claude Code]
mudler
approved these changes
Jun 24, 2026
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.
What
Fixes #10443 — uploading a document to a collection whose name contains a colon (e.g.
legacy-api-key:LiteraryResearch, the auto-created collection for an imported agent) failed with:Root cause
Echo routes a request via
URL.RawPathwhenever the path contains percent-encoded characters (%3Afor:), and in that case stores the matched path-param value still escaped. Soc.Param("name")returnedlegacy-api-key%3ALiteraryResearchinstead of the real name, and the store lookup 404'd.This is second-order fallout of #10375 / #10387: once colons became valid in collection/agent names (the
legacy-api-key:prefix), the URL-decode gap surfaced on every name-bearing endpoint. The collection entry endpoints already worked around it withurl.PathUnescape(c.Param("*")); the:nameparam did not.Fix
decodedParam(c, name)helper thaturl.PathUnescapes the path param (falling back to the raw value on invalid encoding).agent_collections.go) and the agent:nameendpoints (agents.go), which carry the identicallegacy-api-key:prefix and would 404 the same way.Test
Added
agent_collections_param_test.go, a regression test that routes a%3A-encoded path through Echo's real router and asserts the handler observes the decoded name. Verified it fails before the fix (returnslegacy-api-key%3ALiteraryResearch) and passes after.Full
core/http/endpoints/localai/suite passes;golangci-lint --new-from-merge-base=masterreports 0 issues.