Dany Marques
11/22/2022, 11:52 AMMismatch with header 'Accept': Expected 'application/problem+json' to match '^(.*application\/problem\+json.*application\/json.*)|(.*application\/json.*application\/problem\+json.*)$' . When I log the request who was sent, I see the following: "accept": ["application/problem+json", "application/json", "text/plain", "*/*"] . So it looks like Pact interprets the Accept header as an array of string and then only compares the first one with the regex instead of comparing them all together. This was working on previous versions of Pact.
Any idea?Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Dany Marques
11/22/2022, 12:55 PMMatt (pactflow.io / pact-js / pact-go)
; and split it directly here: https://github.com/pact-foundation/pact-js/blob/c6c3fae3d59a9f72e10906b3b14563247c8200cb/src/v3/ffi.ts#L15
Then we would simply call interaction.withRequestHeader multiple times for a given header value, enumerating the second argument (which specifies the header value index) that is currently hard coded to 0Matt (pactflow.io / pact-js / pact-go)
Dany Marques
11/23/2022, 9:38 AM,, during the first iteration, in my example, I’ll have application/problem+json and this has to match the Regex (.*application\/problem\+json.*application\/json.*)|(.*application\/json.*application\/problem\+json.*) and it will not.Dany Marques
11/24/2022, 6:51 AMMatt (pactflow.io / pact-js / pact-go)
Dany Marques
11/28/2022, 3:30 PMDany Marques
11/28/2022, 3:31 PMDany Marques
11/28/2022, 3:33 PMinteraction.withRequestHeader multiple times it’ll not work as in the regex we expect all the values on which we iterate and not only one.Dany Marques
11/28/2022, 3:34 PMDany Marques
11/29/2022, 7:32 AMMatt (pactflow.io / pact-js / pact-go)
Dany Marques
11/30/2022, 6:56 AMMatt (pactflow.io / pact-js / pact-go)
I tried to implement your proposition on Pact JS but as said before, if we callwhy do you need to regex the header at all though? What are you trying to achieve exactly? By specifying you’ll send through those headers, the mock service should check for you anyway.multiple times it’ll not work as in the regex we expect all the values on which we iterate and not only one.interaction.withRequestHeader
Dany Marques
11/30/2022, 7:08 AMAccept header in the request matches the following Regex: (.*application\/problem\+json.*application\/json.*)|(.*application\/json.*application\/problem\+json.*) .
It just means I want contains application/problem+json and application/json .Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Dany Marques
11/30/2022, 8:11 AMapplication/problem+json, application/json . It could also be application/json, application/problem+json . Both are correct for my use case.Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Dany Marques
11/30/2022, 8:12 AMMatt (pactflow.io / pact-js / pact-go)
application/problem+json, application/json and the core will split it into two, and then check against the headers you sentMatt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
accept: ['application/matt', 'text/matt']
And then in your HTTP client:
return axios
.request({
baseURL: mockserver.url,
headers: {
Accept: 'application/matt, text/matt',
},
data: 'hello',
method: 'POST',
url: '/matt',
})
type thing. I think order will matter thoughMatt (pactflow.io / pact-js / pact-go)
Dany Marques
12/01/2022, 7:03 AMMatt (pactflow.io / pact-js / pact-go)
Matt (pactflow.io / pact-js / pact-go)
It’s exactly what I have implemented but it was not solving my issue with the Regex. I’ll test it as soon as I’ve some free time!I think you can drop the regex now though, because you’re able to specify that your client is going to send multiple accept headers
Matt (pactflow.io / pact-js / pact-go)
Dany Marques
12/07/2022, 7:28 AMMismatch with header 'Accept': Expected header 'Accept' to have value 'application/problem+jsonapplication/jsontext/plain*/*' but was 'application/problem+json'.
Something happens with my Accept header as all the commas between the values disappear. Any idea @Matt (pactflow.io / pact-js / pact-go)?Dany Marques
12/07/2022, 7:35 AMType mismatch: Expected Map {"pact:matcher:type":"type","value":false} but received Boolean false.Matt (pactflow.io / pact-js / pact-go)