Issue with query string parsing in 10.11.2
See original GitHub issueSoftware versions
Please provide at least OS and version of pact-js
- OS: tested on Linux and Mac
- Pact Node version: 10.11.2
- Node Version: 12.18.0
FYI just found an issue relating to query string parsing in this version of the standalone. I need to get to the bottom of why, but an example in the JS repo just started failing after upgrade:
Request:
const catsListRequest = {
uponReceiving: "a request for cats with given catId",
withRequest: {
method: "GET",
path: "/cats",
query: {
"catId[]": Matchers.eachLike("1"),
},
headers: {
Accept: "application/json",
},
},
}
Client code:
exports.getMeCats = endpoint => {
const url = endpoint.url
return axios
.request({
method: "GET",
baseURL: url,
url: "/cats?catId[]=2&catId[]=3",
headers: { Accept: "application/json" },
})
.then(response => response.data)
}
Log file:
E, [2021-01-27T22:38:04.829205 #15023] ERROR -- : No matching interaction found for GET /cats?catId[]=2&catId[]=3
E, [2021-01-27T22:38:04.829228 #15023] ERROR -- : Interaction diffs for that route:
E, [2021-01-27T22:38:04.829675 #15023] ERROR -- : Diff with interaction: "a request for cats with given catId" given "i have a list of cats"
Diff
--------------------------------------
Key: - is expected
+ is actual
Matching keys and values are not shown
{
"query": {
- "catId[]": [
- "1",
+ "catId": [
+ "2",
+ "3"
]
}
}
Description of differences
--------------------------------------
* Could not find key "catId[]" (keys present are: catId) at $.query
* Did not expect the key "catId" to exist at $.query
W, [2021-01-27T22:38:04.836258 #15023] WARN -- : Verifying - actual interactions do not match expected interactions.
Incorrect requests:
GET /cats?catId[]=2&catId[]=3 (request query did not match)
W, [2021-01-27T22:38:04.836304 #15023] WARN -- : Incorrect requests:
GET /cats?catId[]=2&catId[]=3 (request query did not match)
I’ll dig into more later, but this was the quickest spot to re-raise the issue
See also
Issue Analytics
- State:
- Created 3 years ago
- Comments:10 (10 by maintainers)
Top Results From Across the Web
Issue with query string parsing in 10.11.2 #256 - GitHub
Yeah, I recall a discussion about dealing with it differently in the v3 code. But I think this is a breaking backwards incompatible...
Read more >Parse query string in JavaScript [duplicate] - Stack Overflow
Here is a fast and easy way of parsing query strings in JavaScript: function getQueryVariable(variable) { var query = window.location.search.substring(1); ...
Read more >RSS issue after 10.11.2 and 10.11.3 upgrade (from 9.11.4) - Help ...
Hi, I upgraded my xwiki 8.11.4 to 10.11.2 (and 10.11.3) and since 10.11.2 my ... query string parameters #set ($queryObject = $services.query.xwql($query).
Read more >@nano-router/url - NPM Package Overview - Socket - Socket.dev
This package provides utilities for working with URLs. Instalation · Usage · Creating a URL · Creating a path · Parsing query parameters...
Read more >Class: Mechanize — Documentation for mechanize (2.7.4)
Issues with mechanize ... Here are some common problems you may experience with mechanize ... query_params is formatted into a query string using ......
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
And BAM https://github.com/pact-foundation/pact-node/pull/258 Like a little Rube Goldberg machine.
I think that’s the right call, thanks.
My local Windows tests didn’t pass either, due to a different problem (possibly Windows long path, hard to tell). A tomorrow problem, too.