New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pact verifier mangles JSON request body #894
Comments
Thanks for the great bug report @iknowcss. I had a quick play in the hotel, and it looks like this line is causing the issue in your case. This seems to mess up the middleware that intercepts the body to allow a In your case, it looks like specifying an explicit I'll look into why this specific pathway comes up in the code, but at least we have some pointers now. |
@mefellows thanks for looking into it! Yeah I noticed the content type is wrong at some point in my investigation. I will change that on my end and confirm it fixes the problem. This is a bit of a weird one I guess because my consumer request is technically wrong (should set the correct header) but my tests broke after a minor upgrade. Maybe you could make the case that the previous version had a bug and the latest version fixes it 🤷♂️ Anyway, thanks again for the help and I will report back soon. |
No worries! I had a chat with a few maintainers this evening to see if I was missing anything, but basically it just happens to be the default (in the Ruby based implementation, which is the 9.x.x line) that it uses the The change we introduced is definitely backwards incompatible, but accidentally so in the way you allude to. I have some ideas as to how I can address this - the primary one is detecting the lack of content type but the presence of what looks to be a single JSON body and warning the user. This would indicate incorrect consumer test case setup. Do you have enough to resolve your immediate issue? |
@mefellows I believe so, I will let you know today once I confirm that adding the content type fixes my problem. |
@mefellows I can confirm that adding in the |
Great, thanks for confirming @iknowcss. I'll get a small patch in the next few days to warn about this situation. Thanks for bringing it to our attention. |
Software versions
Please provide at least OS and version of pact-js
@pact-foundation/pact-node@10.17.2
14.17.6
@pact-foundation/pact@9.18.0
and9.18.1
Issue Checklist
Please confirm the following:
Expected behaviour
Verifier makes a request to the provider with body:
Actual behaviour
Verifier makes a request to the provider with body:
Steps to reproduce
Use the following contract to run the pact verifier against a stub provider:
ExampleContract.zip
Run this command to start a stub provider which echos the request method, url, headers and body:
node -e "const http = require('http'); const server = http.createServer((req, res) => { console.log(req.method + ' ' + req.url); console.log(req.headers); console.log(''); req.on('data', (data) => {process.stdout.write(data);}); req.on('end', () => { console.log('\n');res.end('{}'); }); }); server.listen(1988, () => console.log('running'))"
In
@pact-foundation/pact@9.17.3
the last interaction request looks like this:...but
@pact-foundation/pact@9.18.0
and19.18.1
the last interaction request looks like this:Relevant log files
debug.log
The text was updated successfully, but these errors were encountered: