Support raw BodyInit values in converted server requests - #6989
Conversation
🦋 Changeset detectedLatest commit: d52089e The changes in this PR will be included in the next version bump. This PR includes changesets to release 30 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
There was a problem hiding this comment.
Important
This PR currently adds only the regression test; the implementation fix is still pending. CI is expected to fail until rawBodyStream / rawBodyBytes are updated to handle raw string BodyInit values.
Reviewed changes — Added one test in packages/effect/test/unstable/http/HttpServerRequest.test.ts that verifies HttpServerRequest.fromClientRequest exposes a raw string body via .text.
- Test is well-targeted and fails with the exact bug described (
HttpServerError(RequestParseError): Unsupported body type). - The test uses
it.effectandassert.strictEqualconsistently with the surrounding suite.
@v0 or keep the SHA fresh with Dependabot | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes — Since the prior Pullfrog review, the implementation fix landed on the branch.
- Implemented raw
BodyInithandling inpackages/effect/src/unstable/http/HttpServerRequest.ts:rawBodyStreamandrawBodyBytesnow route standardBodyInitvalues throughnew Response(body)via a newisBodyInitpredicate. - Expanded regression coverage in
packages/effect/test/unstable/http/HttpServerRequest.test.tsto assert.text,.arrayBuffer, and.streambehavior for raw string andURLSearchParamsbodies. - Added a patch changeset describing the fix.
@v0 or keep the SHA fresh with Dependabot | View workflow run | Using Kimi K2 (free via Pullfrog for OSS) | 𝕏
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|

Summary
fromClientRequest preserves a raw string body, but reading it through the server request body accessors fails with HttpServerError(RequestParseError) instead of returning its bytes or text.
Important
This PR starts with focused failing reproduction tests. Add the implementation fix to this same branch; CI is expected to fail until that fix is included.
Client request conversion rejects ordinary raw BodyInit values
Module:
HttpServerRequestAudit ID:
unstable-http-httpserverrequest-raw-bodySeverity / confidence: medium / high
What happens
fromClientRequest preserves a raw string body, but reading it through the server request body accessors fails with HttpServerError(RequestParseError) instead of returning its bytes or text.
Why it happens
HttpBody.raw accepts runtime body values, and strings are valid Fetch BodyInit values, but rawBodyStream only supports Request, FormData, and ReadableStream, while rawBodyBytes only supports Blob and Request. A raw string therefore fails as an unsupported body type.
Expected behavior
fromClientRequest preserves a client's body and exposes it through the server request body accessors.
Relevant implementation
These links and excerpts are pinned to audit base
c9b56ab507f224426ee8388dc450da447ec4715f.packages/effect/src/unstable/http/HttpServerRequest.ts:733-784packages/effect/src/unstable/http/HttpServerRequest.ts:862-886View problematic code at
packages/effect/src/unstable/http/HttpServerRequest.ts:733-782View exact lines on GitHub
Excerpt truncated. Open the complete packages/effect/src/unstable/http/HttpServerRequest.ts:733-784 range.
View problematic code at
packages/effect/src/unstable/http/HttpServerRequest.ts:862-886View exact lines on GitHub
Reproduction
pnpm test --run packages/effect/test/unstable/http/HttpServerRequest.test.tsObserved failure: Failed as intended with HttpServerError(RequestParseError): Unsupported body type.
Implementation handoff
The initial reproduction tests on this branch are the regression specification for the implementation fix that should follow in this PR.
pnpm test --run packages/effect/test/unstable/http/HttpServerRequest.test.tsAudit provenance
c9b56ab507f224426ee8388dc450da447ec4715fc9b56ab507f224426ee8388dc450da447ec4715funstable-http-httpserverrequest-raw-bodyCloses EFF-426