fix(forge_fs): unify is_binary detector in read_range_utf8#3749
Open
MeGaurav4 wants to merge 1 commit into
Open
fix(forge_fs): unify is_binary detector in read_range_utf8#3749MeGaurav4 wants to merge 1 commit into
MeGaurav4 wants to merge 1 commit into
Conversation
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
read_range_utf8used theinfer-basedForgeFS::is_binary(MIME sniff over 8192 bytes, assumes text when the type is unknown), whilefs_search,fs_write,plan_create, andimage_readall used the BOM + zero-byte detector inbinary_detection.rs. A file with a stray0x00in the first 512 bytes was skipped as binary by search but read as text byread_range_utf8.This PR routes
read_range_utf8through the sameis_binary(path)detector used by every other caller, and removes the now-unusedinfer-based implementation, its tests, and theinferdependency.Files changed:
crates/forge_fs/src/read_range.rs: useis_binary(path_ref)instead ofSelf::is_binary(&mut file); add regression testcrates/forge_fs/src/is_binary.rs: deleted (no remaining callers)crates/forge_fs/src/lib.rs: removemod is_binary;crates/forge_fs/Cargo.toml: removeinferdependencyFixes #3633
Verification
cargo test -p forge_fs --libpasses (10 tests, including newtest_stray_zero_byte_classified_as_binary)cargo clippy -p forge_fs --libis cleancargo check -p forge_infraandcargo check -p forge_apppass (no downstream breakage)