Skip to content

fix(forge_fs): unify is_binary detector in read_range_utf8#3749

Open
MeGaurav4 wants to merge 1 commit into
tailcallhq:mainfrom
MeGaurav4:fix/unify-is-binary-detector-3633
Open

fix(forge_fs): unify is_binary detector in read_range_utf8#3749
MeGaurav4 wants to merge 1 commit into
tailcallhq:mainfrom
MeGaurav4:fix/unify-is-binary-detector-3633

Conversation

@MeGaurav4

Copy link
Copy Markdown

read_range_utf8 used the infer-based ForgeFS::is_binary (MIME sniff over 8192 bytes, assumes text when the type is unknown), while fs_search, fs_write, plan_create, and image_read all used the BOM + zero-byte detector in binary_detection.rs. A file with a stray 0x00 in the first 512 bytes was skipped as binary by search but read as text by read_range_utf8.

This PR routes read_range_utf8 through the same is_binary(path) detector used by every other caller, and removes the now-unused infer-based implementation, its tests, and the infer dependency.

Files changed:

  • crates/forge_fs/src/read_range.rs: use is_binary(path_ref) instead of Self::is_binary(&mut file); add regression test
  • crates/forge_fs/src/is_binary.rs: deleted (no remaining callers)
  • crates/forge_fs/src/lib.rs: remove mod is_binary;
  • crates/forge_fs/Cargo.toml: remove infer dependency

Fixes #3633

Verification

  • cargo test -p forge_fs --lib passes (10 tests, including new test_stray_zero_byte_classified_as_binary)
  • cargo clippy -p forge_fs --lib is clean
  • cargo check -p forge_infra and cargo check -p forge_app pass (no downstream breakage)

read_range_utf8 used the infer-based ForgeFS::is_binary (MIME sniff,
8192 bytes, assumes text when type is unknown) while fs_search and
all other callers used the BOM + zero-byte detector in
binary_detection.rs. The same file could be skipped as binary by
search but read as text by read_range.

Route read_range_utf8 through the same is_binary(path) detector and
remove the now-unused infer-based implementation and its dependency.

Fixes tailcallhq#3633
@github-actions github-actions Bot added the type: fix Iterations on existing features or infrastructure. label Jul 23, 2026
@CLAassistant

CLAassistant commented Jul 23, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: fix Iterations on existing features or infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: two divergent is_binary detectors in forge_fs — fs_search/fs_write vs read_range disagree on same file

2 participants