Skip to content

fix(read): prioritize known text extensions - #3848

Open
original4422 wants to merge 1 commit into
tailcallhq:mainfrom
original4422:fix/3812-text-mime-detection
Open

fix(read): prioritize known text extensions#3848
original4422 wants to merge 1 commit into
tailcallhq:mainfrom
original4422:fix/3812-text-mime-detection

Conversation

@original4422

Copy link
Copy Markdown

Summary

  • Treat known text extensions as authoritative before content sniffing, preventing embedded magic-byte literals from turning source files into image/PDF payloads.
  • Preserve infer detection for unknown and extensionless files and preserve the existing extension fallback.
  • Exercise the real ForgeFsRead path and MIME compatibility matrix with same-file regression tests.

Root cause

infer::get scans the entire supplied buffer and recognizes the %PDF sequence at byte offset 449. Limiting the buffer to the issue's suggested 1 KiB would still include that sequence and therefore would not fix this reproduction. The minimal reliable fix is to trust the existing known-text extension allowlist before content sniffing.

Validation

  • cargo test -p forge_services tool_services::fs_read::tests -- --nocapture — 28 passed
  • cargo test -p forge_services — 216 passed; doc tests passed
  • cargo check -p forge_services — passed
  • cargo clippy -p forge_services --all-targets --all-features -- -D warnings — passed
  • cargo fmt -p forge_services -- --check — passed
  • git diff --check — passed

cargo insta test was unavailable because the local cargo-insta command is not installed, so the complete crate suite was run directly with cargo test. A workspace-wide clippy attempt stopped while building the untouched forge_repo crate because local protoc is absent; CI installs protoc, and the touched crate's all-target/all-feature clippy is green.

Fixes #3812

Co-Authored-By: ForgeCode noreply@forgecode.dev

Co-Authored-By: ForgeCode <noreply@forgecode.dev>
Copilot AI lite review requested due to automatic review settings August 20, 2026 01:34

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added the type: fix Iterations on existing features or infrastructure. label Aug 20, 2026
@CLAassistant

CLAassistant commented Aug 20, 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

3 participants