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.

@original4422

Copy link
Copy Markdown
Author

Hi @tusharmath, when you have a chance, would you mind reviewing this MIME-detection fix and letting me know if any changes are needed? Thank you!

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

@github-actions

Copy link
Copy Markdown

Action required: PR inactive for 5 days.
Status update or closure in 10 days.

@github-actions github-actions Bot added the state: inactive No current action needed/possible; issue fixed, out of scope, or superseded. label Aug 29, 2026
@original4422

Copy link
Copy Markdown
Author

Status update: this PR is still active and ready for review. The current head remains c8f0320e721b4adaf0bd889c1f7f60456f6f295a and GitHub reports it mergeable.

Validation recorded for this unchanged head includes 28/28 focused fs_read tests, 216/216 forge_services tests, plus passing crate cargo check, all-target/all-feature clippy, and formatting. CLA Assistant confirms all committers have signed. The ci, Bounty Management, and autofix.ci runs remain at the external-contributor action_required gate with zero jobs, so there is no actionable test failure log; Release Drafter passed.

Maintainers, could you please review this when available and approve the gated workflows if appropriate? Thank you.

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

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

Labels

state: inactive No current action needed/possible; issue fixed, out of scope, or superseded. type: fix Iterations on existing features or infrastructure.

Projects

None yet

3 participants