Fix double encoding of URI template parameter names for list/associative-array values - #5280
Merged
iscai-msft merged 5 commits intoAug 31, 2026
Merged
Conversation
…ive-array values The scalar-value path in expandUrlTemplate already preserved a pre-encoded variable name, but the array/list path (getExpandedValue) and the non-expanded/associative-array path (getNonExpandedValue) still called encodeComponent/encodeURIComponent on varName, causing double encoding (e.g. "%24Select" becoming "%2524Select"). Fixes Azure#5278 Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
Contributor
📦 Package size report2 packages changed size, +6.25 KB (+0.0%) packed overall.
11 package(s) with no notable change
Packed = gzipped |
Contributor
|
You can try these changes here
|
Maor Leger (maorleger)
approved these changes
Aug 21, 2026
Maor Leger (maorleger)
left a comment
Member
There was a problem hiding this comment.
The fix LGTM but I'd love to get confirmation from the emitter folks
Thanks for putting that together!
Jialin Huang (JialinHuang803)
approved these changes
Aug 24, 2026
Member
|
The fix LGTM, thank you! |
… encoding Addresses review feedback from @maorleger on PR Azure#5280. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
The changeset used the shorthand format which chronus no longer supports, causing the Check Changes CI job to fail with ChronusDiagnosticError. Updated to the standard changeKind/packages frontmatter. Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com>
iscai-msft
enabled auto-merge
August 31, 2026 19:38
Contributor
|
All changed packages have been documented.
Show changes
|
commit: |
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
Fixes #5278
Query parameter names are pre-encoded by the emitter (e.g.
$Select→%24Select) before being passed as URI template variable names. The scalar-value expansion path inexpandUrlTemplatealready accounted for this and skipped re-encoding the variable name, but the array-expansion path (getExpandedValue) and the associative-array/list path (getNonExpandedValue) still calledencodeURIComponent/encodeComponentonvarName, causing it to be encoded twice (e.g.%24Selectbecoming%2524Select).Fix
Removed the redundant re-encoding of
varNamein bothgetExpandedValueandgetNonExpandedValueinpackages/typespec-ts/static/static-helpers/urlTemplate.ts, matching the existing (correct) behavior of the scalar-value path.Testing
Added repro tests in
packages/typespec-ts/test/modular-unit/static/url-template.test.tscovering scalar, list, and associative-array query parameter values with a pre-encoded parameter name (%24Select). Verified the new list/associative-array tests fail onmainwith the exact reported symptom (%2524Select) and pass with this fix. All 67 tests in the file pass.Also ran
pnpm linton the touched package (clean).