Skip to content

Conversation

YOU54F
Copy link
Member

@YOU54F YOU54F commented Sep 5, 2025

In creating test for the pact_broker-client rewrite in rust, I need to coerce the Pact files to V2.

This gives me issues with the ordering of certain query string parameters which are expected after the specified participant.

This PR looks to introduce a failing test, and a fix for the issue

this is probably easier just to rewrite the query string order on the provider side verification in ruby
@YOU54F
Copy link
Member Author

YOU54F commented Sep 5, 2025

Hmm still not quite quite

                        .path("/matrix")
                        .query_param("q[][pacticipant]", "Foo")
                        .query_param("q[][version]", "1.2.3")
                        .query_param("q[][pacticipant]", "Bar")
                        .query_param("q[][latest]", "true")
                        .query_param("q[][tag]", "prod")
                        .query_param("latestby", "cvpv");

should return ordering like

query: "q%5B%5D%5Bpacticipant%5D=Foo&q%5B%5D%5Bversion%5D=1.2.3&q%5B%5D%5Bpacticipant%5D=Bar&q%5B%5D%5Blatest%5D=true&q%5B%5D%5Btag%5D=prod&latestby=cvpv"

but returns

"query": "latestby=cvpv&q[][latest]=true&q[][pacticipant]=Foo&q[][tag]=prod&q[][version]=1%2e2%2e3&q[][pacticipant]=Bar"

I'll just overwrite the headers in the pact broker verification task instead

@YOU54F YOU54F marked this pull request as draft September 5, 2025 16:38
@rholshausen
Copy link
Contributor

rholshausen commented Sep 8, 2025

The issue is that the queries are stored in a HashMap, which does not guarantee the orders of the entries. If you want to keep the order of the parameters, it will need to use something else. BTreeMap can guarantee the order of the entries, but that is by keeping them in sorted order.

@rholshausen
Copy link
Contributor

See https://stackoverflow.com/questions/30243100/how-do-i-sort-a-map-by-order-of-insertion

BTW, changing the map type would be a breaking change as those structs are used everywhere.

@YOU54F
Copy link
Member Author

YOU54F commented Sep 12, 2025

Thanks for the additional reference! Ahh well, if no-one else is requesting it, probably not worth the effort.

Will park this for now, as have passing tests with some query string overrides

@YOU54F YOU54F closed this Sep 12, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants