-
-
Notifications
You must be signed in to change notification settings - Fork 50
fix(test): update decompress: false test to match actual parsing behavior #359
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
Conversation
jsumners
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do see the changed test failing with a fresh checkout and run of the test suite. But the changes in this PR are not an appropriate solution.
…R_CTP_INVALID_CONTENT_LENGTH
|
Thanks for the feedback @jsumners I've addressed the points you raised:
All tests pass and the PR description has been updated for clarity. Let me know if there's anything else you'd like to adjust! |
mcollina
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Fdawgs
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is #342 not the fix for this?
Thanks for the question! PR #342 does address the invalid content-type issue, but the test still passes even when decompress: false is set — likely due to a false positive caused by how the stream is handled. This PR focuses specifically on correcting that test to ensure it fails as expected when decompression is disabled. It's more of a test logic fix rather than a functionality change. If you think this improvement should be integrated into #342 instead, I'm totally open to that — just let me know! |
This PR updates the test case for the
decompress: falseroute option infastify-compress.What was done
This PR improves test coverage and aligns expectations with Fastify’s actual behavior regarding compressed request bodies.
Changes
Fixed broken test for
decompress: falseroute optionFST_ERR_CTP_INVALID_CONTENT_LENGTH."Unexpected token ... in JSON".Added test for
FST_ERR_CTP_INVALID_CONTENT_LENGTHContent-Lengthheader does not match the body size.Why these changes are correct
decompress: falseis explicitly set, Fastify does not attempt to decompress the body. A compressed payload will therefore be parsed directly as JSON, resulting in a syntax error — this is expected behavior.FST_ERR_CTP_INVALID_CONTENT_LENGTHerror is only thrown when there’s an actual mismatch between declaredContent-Lengthand the received payload — a different edge case now properly covered.Test Validation
npm run test✔️npm run test:typescript✔️routes-decompress.test.jswith clear scenario coverage ✔️Related
Closes #351
✅ Checklist