Skip to content

fix: forward multipart/form-data fields when a request has no files - #185

Merged
morcen merged 1 commit into
mainfrom
fix/issue-116-multipart-no-files
Jul 28, 2026
Merged

fix: forward multipart/form-data fields when a request has no files#185
morcen merged 1 commit into
mainfrom
fix/issue-116-multipart-no-files

Conversation

@morcen

@morcen morcen commented Jul 27, 2026

Copy link
Copy Markdown
Owner

What was broken

PassageService::callService() only entered the multipart-aware branch when $request->allFiles() was non-empty. A multipart/form-data request with only text fields (no file fields) — a completely standard form submission — matched none of the earlier branches and fell into the raw-passthrough fallback, which builds the outbound body from $request->getContent().

PHP consumes php://input while populating $_POST/$_FILES during request initialization for multipart requests, before any userland code runs, so getContent() is always empty for them. The fallback branch's $body !== '' check was therefore always false, and the upstream call was dispatched with no body and none of the submitted fields — silently, with no error or exception.

What changed

  • src/Services/PassageService.php: widened the multipart-handling condition to also trigger when the Content-Type header contains multipart/form-data (checked case-insensitively, matching the convention already used in HasHmacAuth), not just when files are present. Text-only multipart requests are now forwarded via $request->post(), the same as the existing file-upload path.
  • tests/Unit/PassageServiceTest.php: added regression tests covering a multipart/form-data POST with only text fields (asserting the fields reach the outbound request), and one covering case-insensitive Content-Type detection.

Testing

  • vendor/bin/pint --dirty — passed
  • composer test — full suite passes (156 tests, 422 assertions)

Fixes #116

PassageService::callService() only entered the multipart-aware branch
when allFiles() was non-empty, so a plain multipart/form-data request
with only text fields fell through to the raw passthrough branch,
which reads getContent(). PHP consumes php://input while populating
$_POST/$_FILES for multipart requests before userland code runs, so
getContent() is always empty for them, and the upstream call was
dispatched with no body and none of the submitted fields.

Detect multipart/form-data by Content-Type as well as by the presence
of files, so text-only multipart requests are still forwarded via
$request->post() instead of silently dropping the payload.
@morcen
morcen merged commit 260057b into main Jul 28, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PassageService silently drops the entire body of multipart/form-data requests that contain no file fields

1 participant