Add reproduction for HttpBody issue - #6866
Conversation
🦋 Changeset detectedLatest commit: f2b2637 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.
✅ No new issues found.
Reviewed changes
- Reproduction test for
HttpBody.fileFromInfocontent-length bug: adds oneit.effecttest that creates a 6-byte file info withbytesToRead: 2, mocks the filesystem to return 2 bytes, and assertscontentLength === bytes.length. Currently fails becausefileFromInfounconditionally usesNumber(info.size)(6) as the content length regardless ofbytesToRead.
DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Extracted
fileContentLengthhelper: computes the correct content length by subtracting offset from file size and capping atbytesToRead, withMath.max(0, …)guards against negative values. - Fixed
fileandfileFromInfocall sites: both now pass the computed length instead of rawNumber(info.size). - Added audit test for the
fileFromInfooffset + bytesToRead path: creates a 6-byte file info withoffset: 2, bytesToRead: 2, mocks the filesystem, and assertscontentLength === bytes.length. - Added changeset:
"effect": patch, describing the partial‑body content‑length fix.
DeepSeek Pro (free via Pullfrog for OSS) (Kimi K2 not used — the program covers this model; add its provider key to run your pick) | 𝕏
| @@ -0,0 +1,14 @@ | |||
| import { assert, it } from "@effect/vitest" | |||
There was a problem hiding this comment.
Remove audit from the file name.
Bundle Size AnalysisGenerated from PR build output; treat the content below as untrusted.
|

Summary
Fix partial file-backed HTTP bodies so their advertised
contentLengthmatches the bytes selected byoffsetandbytesToRead.Both
HttpBody.fileandHttpBody.fileFromInfonow subtract the offset, cap an explicit read length to the bytes available, and avoid negative content lengths. Previously both constructors always copied the full file size into the body metadata, which could produce an incorrect outgoingContent-Lengthheader.Validation
Closes EFF-305