fix: Send each query parameter value at its own index - #27
Merged
surpher merged 1 commit intoJul 30, 2026
Conversation
mkieselmann
force-pushed
the
fix/query-param-multiple-values
branch
2 times, most recently
from
July 29, 2026 16:03
b0fc686 to
77fecd1
Compare
mkieselmann
force-pushed
the
fix/query-param-multiple-values
branch
from
July 29, 2026 16:07
77fecd1 to
baf7667
Compare
surpher
approved these changes
Jul 30, 2026
|
@surpher Thanks for looking into this and merging the PR. Would you mind creating a new Release with that fix so that we can use it in https://github.com/surpher/PactSwift/tree/feat/v2.0.0? |
|
Hi @surpher, just checking if it would be possible to create a new release with this. I could then create a PR to have PactSwift consume the new version. Thanks. |
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.
Problem
Interaction.Request.queryParam(name:values:)joined all values with a comma and passed the result topactffi_with_query_parameter_v2at index0. An expectation set up with["foo", "bar"]was therefore recorded as the single value"foo,bar", so a consumer actually sending?item=foo&item=barfailed to match its own pact:This makes repeated query keys impossible to contract-test.
History
The correct behaviour was implemented in 4c01bec already but has been replaced it with
values.joined(separator: ",")and a single index-0call.A fix has been applied in 5cd4fab, but only for headers not for the query.
withHeader(handle:name:values:interactionPart:)has kept the correct shape ever since and served as the template for this fix.Change
withQueryParameternow mirrorswithHeaderand calls the FFI once per value with its offset, so each value is recorded as its own occurrence of the key.Sources/Protocols/PactFFIProviding.swiftwithQueryParameter(handle:name:value: String)→values: [String]Sources/Services/DefaultPactFFIProvider.swiftvalues.enumerated()loop; empty array delegates towithQueryParameterWithoutAssociatedValueSources/Model/Interaction+Request.swiftjoined(separator:); documented multi-value and empty-array semanticsTests/Support/MockPactFFIProvider.swiftTests/PactBuilderTests.swiftThe public API (
queryParam(name:values:)) is unchanged — this only corrects how those values reach the FFI.Behaviour change
An empty
valuesarray previously produced?name=(empty-string value, via[].joined() == ""). It now produces?namewith no associated value, by delegating to the — until now unreachable —withQueryParameterWithoutAssociatedValue, matching the NULL form documented by the FFI. The existingtestInteractionWithQueryParameterscase("baz", [])was updated accordingly.