fix: correct multipart upload boundary mismatch and add real-HTTP-transport tests - #233
Open
morcen wants to merge 1 commit into
Open
fix: correct multipart upload boundary mismatch and add real-HTTP-transport tests#233morcen wants to merge 1 commit into
morcen wants to merge 1 commit into
Conversation
PassageService forwarded the client's original Content-Type header (including its multipart boundary) even when the multipart branch goes on to build an entirely new multipart body via attach(). Guzzle generates a fresh random boundary for that body and only sets a matching Content-Type header when none is already present on the request, so the forwarded header's boundary silently won instead and never matched the boundary actually used in the body. Every multipart file upload proxied through Passage was corrupted on the wire as a result, undetected because the existing Http::fake()-based test suite never serializes the outgoing body or validates it against the Content-Type header. The multipart branch now excludes the client's Content-Type header from what gets forwarded, letting Guzzle set the boundary-correct one itself. Also adds a real-HTTP-transport integration test lane (tests/Feature/PassageRealServerIntegrationTest.php), proxying through an actual PHP built-in web server instead of Http::fake(), covering body types, header forwarding, query forwarding, streaming, and the allowed-hosts guard — this class of bug is invisible to a fake-based HTTP layer.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was broken
PassageService::callService()forwarded the client's originalContent-Typeheader (including its multipart boundary) even when the multipart branch goes on to build an entirely new multipart body via Guzzle'sattach(). Guzzle generates a fresh random boundary for that body and only sets a matchingContent-Typeheader when none is already present on the request, so the forwarded header's boundary silently won instead and never matched the boundary actually used in the body.Every multipart file upload proxied through Passage was corrupted on the wire as a result — undetected because the existing test suite exclusively uses
Http::fake(), which never serializes the outgoing body or validates it against theContent-Typeheader, so a boundary mismatch of this kind is invisible to it.What changed
src/Services/PassageService.php: the multipart branch now excludes the client'sContent-Typeheader from what gets forwarded, letting Guzzle set the boundary-correct header itself.tests/Feature/PassageRealServerIntegrationTest.php(new): a real-HTTP-transport integration lane that proxies requests through an actual PHP built-in web server (tests/Fixtures/real-server-router.php) instead ofHttp::fake(), covering JSON/urlencoded/multipart body forwarding, header forwarding, query forwarding, streaming, and the allowed-hosts guard — exactly the class of bug a fake-based HTTP layer can't catch.tests/Unit/PassageServiceTest.php: added a focused unit test asserting the client'sContent-Typeheader is excluded fromwithHeaders()for a multipart request (verified this test fails without the fix and passes with it).Notes
Building the real-server test lane requested in #87 is what surfaced this bug in the first place — it's exactly the "riskiest audit findings" scenario that issue describes as invisible to a fake-only suite. The coverage-gate portion of #87 (enabling a coverage driver/floor in CI) is out of scope here and left as follow-up work.
Fixes #87