Blob: drop is_bun_file, a duplicate of needs_to_read_file - #39158
Conversation
|
Warning Review limit reachedYou’ve reached a temporary PR review limit under our Fair Usage Limits Policy. Next review available in: 38 minutes Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available. How can I continue?After more reviews become available, a review can be triggered using the To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews. How do review limits work?CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability. For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window. Please refer docs for additional details. Review details⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (5)
Comment |
|
Status: ready to merge from my side.
|
There was a problem hiding this comment.
LGTM — mechanical de-duplication of two byte-identical predicates.
What was reviewed:
- Confirmed the deleted
is_bun_filebody was identical toneeds_to_read_file(bothmatches!(… Store::File(_))), so the two retargeted callers cannot change behavior. - Grepped
src/foris_bun_file/isBunFile— only the localis_bun_file_blobhelper in CryptoHasher.rs remains (now callingneeds_to_read_file); no stragglers. - The
mordant-baseline.tomledit removes exactly the onereimplemented_helper:src/jsc/webcore_types.rsentry; the Blob.rs changes are comment-only.
Extended reasoning...
Overview
This PR deletes Blob::is_bun_file() from src/jsc/webcore_types.rs, whose body was byte-identical to Blob::needs_to_read_file() (both check store.data is Store::File). The two callers of the deleted method — Response.rs (getCompleteWebRequestOrResponseBodyValueAsArrayBuffer) and CryptoHasher.rs (is_bun_file_blob) — are pointed at the surviving needs_to_read_file(). The corresponding reimplemented_helper entry is removed from mordant-baseline.toml, and two stale comments in webcore/Blob.rs that named the deleted method are cleaned up.
Security risks
None. This is a pure rename at two call sites plus a method deletion; no input handling, permissions, or crypto logic changes. The CryptoHasher touch only changes which identically-bodied predicate gates the existing "Bun.file() not supported here" throw.
Level of scrutiny
Low. The two method bodies were provably identical (visible in the diff), so retargeting callers cannot change runtime behavior. A repo-wide grep confirms no remaining is_bun_file references in src/, so any missed caller would be a compile error, not a silent behavior change. The baseline edit is a single-line removal of the entry this PR resolves.
Other factors
The PR description documents thorough verification: the mordant lint is confirmed clean and confirmed to re-fire with the old code on the trimmed baseline; the CryptoHasher and Blob/Response test suites pass on the debug build. The one noted pre-existing failure (blob.test.ts slice streaming) reproduces on clean main and is unrelated. The author also flagged two in-flight PRs that add is_bun_file() calls — those will fail to compile rather than silently diverge, which is the desired outcome.
Both predicates had the same body (store is Some and its data is Store::File), so a change to one would have missed the other. Keep needs_to_read_file, which nearly every caller already uses, point the two is_bun_file callers at it, and remove the matching reimplemented_helper entry from the mordant baseline. No behavior change.
fb64f64 to
a880009
Compare
There was a problem hiding this comment.
LGTM — mechanical dedup of two byte-identical predicates.
What was reviewed:
- Confirmed
is_bun_fileandneeds_to_read_filehad identical bodies; the two rewired call sites (Response.rs,CryptoHasher.rs) now use the same predicate the rest of the tree already uses — no behavior change. - Grepped for remaining
is_bun_filereferences: only the localis_bun_file_blobhelper inCryptoHasher.rsremains (its body was updated), so no stray callers. - Baseline entry removal and comment cleanups match the deleted method.
Extended reasoning...
Overview
This PR removes Blob::is_bun_file() from src/jsc/webcore_types.rs, which was byte-for-byte identical to Blob::needs_to_read_file() (both check whether the store is Some with Store::File data). The two call sites of the deleted method — Response.rs (getCompleteWebRequestOrResponseBodyValueAsArrayBuffer) and CryptoHasher.rs (is_bun_file_blob helper) — are pointed at the surviving predicate. The corresponding reimplemented_helper mordant baseline entry is removed, along with two stale comments in webcore/Blob.rs that named the deleted method.
Security risks
None. This is a pure dedup of two identical predicates on an internal Rust type; no user-facing behavior, input handling, or trust boundaries are touched.
Level of scrutiny
Low. The deleted function and the surviving one had the same signature and the same body, so replacing one call with the other is provably behavior-preserving. This matches the shape of several recently-merged PRs from the same mordant-cleanup batch (#39124, #39140, #39141, #39123). REVIEW.md explicitly asks for this: "If your fix makes two functions byte-identical, delete one."
Other factors
- I grepped the tree for
is_bun_file/isBunFileand confirmed the only remaining hits are the localis_bun_file_blobhelper inCryptoHasher.rs(whose body now callsneeds_to_read_file()); any missed caller would be a compile error, not a silent change. - The PR description documents that
bun run rust:mordantis clean on this branch and fails when main'swebcore_types.rsis restored on top of the trimmed baseline, confirming the removed entry was this exact site. - No new test is warranted since there is no observable behavior to distinguish before from after; existing coverage (
bun-cryptohasher.test.ts) already pins theBun.file()rejection at theCryptoHashercall site. - No prior reviews or outstanding comments on this PR.
There was a problem hiding this comment.
LGTM — mechanical dedup of two byte-identical predicates.
What was reviewed:
- Confirmed
is_bun_fileandneeds_to_read_filehad identical bodies; the two callers (Response.rs,CryptoHasher.rs) now call the survivor with no behavior change. - Grepped
src/for remainingis_bun_filereferences — none (the localis_bun_file_blobhelper in CryptoHasher is a distinct name). - The
mordant-baseline.tomlentry removal is enforced by the mordant CI job, so a resurfaced finding would fail the workflow.
Extended reasoning...
Overview
Deletes Blob::is_bun_file() from src/jsc/webcore_types.rs — its body was byte-for-byte identical to Blob::needs_to_read_file() (both check matches!(self.store..., Some(s) if matches!(s.data, Store::File(_)))). Points the two remaining callers at needs_to_read_file(), removes stale comments in webcore/Blob.rs that named the deleted method, and drops the corresponding reimplemented_helper entry from mordant-baseline.toml.
Security risks
None. This is a pure rename/dedup of a data-only predicate with no I/O, allocation, or user-input handling.
Level of scrutiny
Low. The two predicates were provably identical, so substituting one for the other cannot change behavior. Any missed caller would be a compile error, not a silent regression. The baseline-entry removal is CI-enforced (the mordant workflow re-runs when the baseline file changes and fails if the finding still fires). REVIEW.md explicitly calls for this shape: "If your fix makes two functions byte-identical, delete one."
Other factors
- The
CryptoHashercall site's observable behavior (rejectingBun.file()input) is already covered bybun-cryptohasher.test.ts. - No new test is expected: the change has no observable delta to pin, and REVIEW.md's "every behavioral change ships an automated test" does not apply to a non-behavioral dedup.
- The PR description flags two open PRs that add
is_bun_file()calls; those will surface as compile errors when rebased, not silent breakage. - No prior review from me on this PR; no outstanding human reviewer comments.
Problem
reimplemented_helperfinding baselined forsrc/jsc/webcore_types.rs:Blob::is_bun_fileandBlob::needs_to_read_filehad the same signature and the same body (the store isSomeand its data isStore::File), so a change to one would have silently missed the other.Blob.zigalready hadisBunFileandneedsToReadFilewith the same body, and neither side has changed since the port (Rewrite Bun in Rust #30412). Nothing relies on them differing.Fix
is_bun_fileand keepneeds_to_read_file, which is what the ~40 other call sites (and theblob_needs_to_read_filehook thatbun_sql_jscgoes through) already use.is_bun_filecallers at it:Response.rs(getCompleteWebRequestOrResponseBodyValueAsArrayBufferreturnsundefinedfor a file-backed body) andCryptoHasher.rs(the synchronous hashers rejectBun.file()input). Same predicate, so no behavior change.reimplemented_helper:src/jsc/webcore_types.rsentry frommordant-baseline.toml, and the two stale comments inwebcore/Blob.rsthat named the deleted method. The entry is removed by hand rather than by regenerating the file: a fullbun run rust:mordant:baselineon Linux also drops two unrelated entries (always_unwrapped_optioninPackageInstall.rs,narrowed_two_waysinnode_crypto_binding.rs) that this PR has no business touching.Bun.file()rejection at theCryptoHashercall site is already covered bybun-cryptohasher.test.ts("Bun.file in CryptoHasher is not supported yet"), and the mordant run below is the check for the finding itself. Same shape as bun:ffi: remove ABIType::param_typename, a copy of ABIType::typename #39124, yaml: map StringifyError to JsError in one place #39116 and sql: set a cell's column index and kind in one place #39135 from this batch.bun run rust:mordant(full workspace) on this branch: clean, notarget/mordant/over-baseline.txt. With main'swebcore_types.rsrestored on top of the trimmed baseline it reportsreimplemented_helper ... over the mordant baseline (0 recorded for src/jsc/webcore_types.rs)and1 finding(s) over the baseline in bun_jsc, so the entry was this site and the lint no longer fires.mordantworkflow also runs on this PR since the baseline changed; with the entry removed it fails if the finding is still reported.bun bd test test/js/bun/util/bun-cryptohasher.test.ts(covers theCryptoHashercall site:Bun.file()input still throws): 402 pass.bun bd testontest/js/web/fetch/{blob,blob-write,body,blob-file-name-ownership,response}.test.ts,test/js/web/structured-clone-blob-file.test.tsandtest/js/bun/io/bun-write.test.js(--timeout 60000, since several of these spawn a debug+ASAN child and exceed the 5s default): everything passes exceptblob.test.ts"Bun.file(path).slice(start, end) streams only the slice", which fails identically on a clean checkout of main (88a6398) and is being handled separately; it is aFileReaderstreaming bug unrelated to this predicate.is_bun_file()calls inBlob.rs(MovenameandlastModifiedfromBlob.prototypetoFile.prototype#32434, Bun.file: make exists()/size/lastModified reflect the current filesystem state #33659); whichever lands after this one needs those calls renamed toneeds_to_read_file(). That is a compile error, not a silent change.Background
Blob(src/jsc/webcore_types.rs) is a view (offset + size) onto a refcountedStore, whosedatais one ofBytes(in memory),File(a path or fd; whatBun.file()creates) orS3.needs_to_read_file()asks whether the blob isFile-backed, i.e. whether its bytes have to be read off disk before anything in memory can look at them; synchronous consumers use it to bail out.rust-lintsworkflow runs (bun run rust:mordant).mordant-baseline.tomlholds the per-(lint, file) counts of findings that predate the job, so CI only fails when a count goes up; once a baselined finding is fixed its entry is deleted.