Skip to content

fix(tools): make rag file extension detection case-insensitive#6514

Open
ALDRIN121 wants to merge 1 commit into
crewAIInc:mainfrom
ALDRIN121:fix/case-insensitive-file-extension-detection
Open

fix(tools): make rag file extension detection case-insensitive#6514
ALDRIN121 wants to merge 1 commit into
crewAIInc:mainfrom
ALDRIN121:fix/case-insensitive-file-extension-detection

Conversation

@ALDRIN121

Copy link
Copy Markdown

Summary

Fixes #6399

DataTypes.from_content() in lib/crewai-tools/src/crewai_tools/rag/data_types.py matched file extensions case-sensitively against a lowercase-only extension map, so files or URLs with uppercase/mixed-case extensions (Report.PDF, data.CSV, doc.DOCX) were silently misrouted to the plain-text loader (or the website loader for URLs). For a PDF this means raw binary bytes get chunked and embedded into the RAG store instead of parsed document text. Uppercase extensions are common on Windows, scanners, and enterprise document exports.

Changes

  • Lowercase the path before the extension comparison in get_file_type() (one-line fix)
  • Add tests/rag/test_data_types.py with regression coverage: 12 parametrized file-extension cases (lower/upper/mixed case) plus URL detection cases

Verification

  • The new tests fail on main (7 failures — exactly the uppercase/mixed-case inputs) and pass with the fix (14/14)
  • Full tests/rag/ + tests/tools/rag/ suite: 176 passed
  • ruff check, ruff format, strict mypy, and pre-commit hooks all pass
Input Before After
report.PDF text_file pdf_file
data.CSV text_file csv
doc.DOCX text_file docx
https://example.com/file.PDF website pdf_file

Uppercase or mixed-case file extensions (.PDF, .CSV, .DOCX) were
misrouted to the text loader because DataTypes.from_content matched
extensions case-sensitively. Lowercase the path before comparison so
Report.PDF resolves to PDF_FILE instead of TEXT_FILE.

Fixes crewAIInc#6399
@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: facaffd3-c3d5-4697-b32b-305a98625400

📥 Commits

Reviewing files that changed from the base of the PR and between 85c467d and e00bb87.

📒 Files selected for processing (2)
  • lib/crewai-tools/src/crewai_tools/rag/data_types.py
  • lib/crewai-tools/tests/rag/test_data_types.py

📝 Walkthrough

Walkthrough

DataTypes.from_content() now performs case-insensitive extension detection. Tests cover local files with multiple suffixes and PDF URLs in uppercase and lowercase.

Changes

RAG file detection

Layer / File(s) Summary
Normalize extension matching
lib/crewai-tools/src/crewai_tools/rag/data_types.py
Lowercases input paths before matching file extensions while preserving the existing type mappings.
Validate case-insensitive detection
lib/crewai-tools/tests/rag/test_data_types.py
Adds temporary-file and URL tests covering supported extensions across uppercase, lowercase, and mixed-case forms.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed Title clearly summarizes the case-insensitive RAG extension detection fix.
Description check ✅ Passed Description matches the bug fix and the added regression tests.
Linked Issues check ✅ Passed Changes satisfy #6399 by lowercasing paths and adding case-insensitive coverage for files and URLs.
Out of Scope Changes check ✅ Passed No obvious out-of-scope changes; edits stay within the file-type detection fix and its tests.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[BUG] RAG file-type auto-detection is case-sensitive — uppercase extensions (.PDF, .CSV, .DOCX) misrouted to the text loader

1 participant