Fix: Don't pre-urlencode Postman collection query keys/values#1075
Merged
shalvah merged 2 commits intoJun 8, 2026
Conversation
Per the Postman Collection v2.1 schema, `query[].key` and `query[].value` are stored as raw strings — Postman encodes them when assembling the outgoing request. Pre-encoding here causes a double-encode on send (e.g. a comma in `?include=customer,reward` becomes `%2C` in the collection, then `%252C` when Postman sends), which trips request parsers like Spatie QueryBuilder that split on a literal `,`. URL parameter `value`s had the same issue. The `raw` URL field still needs to be a syntactically valid URL string, so `rawurlencode()` is applied only when assembling that string. Adds a regression test covering comma + bracket + space cases.
The fixture stored a pre-encoded query value and a `+`-style space in the raw URL. After de7d49d, the writer keeps key/value pairs decoded and renders the raw URL via rawurlencode (RFC 3986 — `%20` for space). Fixture refreshed accordingly.
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
PostmanCollectionWriter::generateUrlObject()callsurlencode()on every query parameter key and value (and on URL parameter values) before writing them to the collection. Per the Postman Collection v2.1 schema,query[].key/query[].valueandvariable[].valueare stored as raw strings — the Postman client encodes them when it assembles the outgoing HTTP request.Pre-encoding here causes a double-encode on send. For example:
Generates this in
collection.json:{ "key": "include", "value": "customer%2Creward" }When the user clicks Send, Postman encodes the value again → server receives
?include=customer%252Creward. Frameworks decode once →customer%2Creward, which strict request parsers (e.g. Spatie QueryBuilder, which splits includes on a literal,) reject as a single unknown include.URL parameter values had the same issue.
What changed
query[].key,query[].value,variable[].valueare now stored unencoded.rawURL field still needs to be a syntactically valid URL, sorawurlencode()is applied only when assembling that string. (Switched torawurlencodebecauseurlencodeencodes spaces as+, which is only valid inapplication/x-www-form-urlencodedbodies — not query strings per RFC 3986.)Tests
PostmanCollectionWriterTestpass unchanged. They only used plain alphanumeric values (5,34,foobar) where pre-encoding was a no-op, which is why this latent bug went unnoticed.query_parameter_keys_and_values_are_not_pre_url_encoded) covering comma + bracket + space cases, asserting:query[]entries store raw valuesvariable[]entries store raw valuesrawURL is encoded for HTTP validityRelated
Notes for reviewers
This is a behavioral change visible in generated Postman collections. Users who imported a previously-generated collection and observed
%2C/%5B/%5Din the displayed key/value will now see literal,/[/]. Postman renders both forms identically when sending, so no user-facing regression — only the underlying double-encode bug is fixed.