fix(http): substitute path parameters only by their whole name - #7914
Merged
Merged
Conversation
The HTTP request tool replaced each path parameter with a plain string
replace of `:${key}` over the whole URL. An empty key stripped the colon
from the scheme, so `https://host` became `https//host` and the request
was refused as not absolute; a numeric key rewrote the port into the host;
and `:id` matched inside `:idx`. Models occasionally send an empty
path-parameter entry, which made agent API tool calls fail intermittently.
Substitute a key only when it starts like a JavaScript identifier, as
path-to-regexp defines `:name` parameters, and end each placeholder where
an identifier ends.
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
Contributor
|
Collaborator
Author
Collaborator
Author
|
@cubic-dev-ai review this PR |
Contributor
@waleedlatif1 I have started the AI code review. It will take a few minutes to complete. |
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.
Summary
:${key}across the whole URLhttps://host→https//host), so the request was refused as not an absolute URL. Models occasionally send an empty path-parameter entry, which made agent API tool calls fail intermittentlyhost:8443→hostx), and:idmatched inside:idxID_Start/ID_Continueclasses (an empty name is a "Missing parameter name" error there), and a placeholder ends where an identifier ends. Longer keys are substituted first, so:user-idis never consumed by auserkey whatever orderpathParamslists them in. Keys with.,-,$or non-ASCII letters keep working, the value is still URL-encoded, and it is inserted literally so$&in a value is not a replacement pattern:idno longer substitutes into:id_suffixor:id1, which path-to-regexp reads as different parameter names.pathParamsis only ever supplied as a tool argument; no block stores itType of Change
Testing
processUrltests for an empty key, a numeric key next to a port, a/key,:idvs:idx, auserkey next to:user-idand:user.name, Unicode keys, a literal-after a placeholder, hyphenated / dotted /$-prefixed keys, and a value containing$&; the empty-key case fails on the previous implementation withhttps//www.google.comviteston the HTTP tool, tool execution and agent handler suites (421 passing)bun run lint,bun run check:audits,docs-manifest:check, andbun run type-checkpassingChecklist