Skip to content

fix: make RAG file-type detection case-insensitive#6487

Open
xbrxr03 wants to merge 1 commit into
crewAIInc:mainfrom
xbrxr03:fix/rag-case-insensitive-ext
Open

fix: make RAG file-type detection case-insensitive#6487
xbrxr03 wants to merge 1 commit into
crewAIInc:mainfrom
xbrxr03:fix/rag-case-insensitive-ext

Conversation

@xbrxr03

@xbrxr03 xbrxr03 commented Jul 8, 2026

Copy link
Copy Markdown

Closes #6399

Problem: DataTypes.from_content() uses case-sensitive path.endswith(ext) against a lowercase-only extension map. Files with uppercase/mixed-case extensions (.PDF, .CSV, .DOCX) are silently misrouted to the text loader, causing raw binary bytes to be chunked and embedded into the RAG store instead of parsed document text.

Fix: Lowercase the path before extension matching:

lower_path = path.lower()
for ext, dtype in mapping.items():
    if lower_path.endswith(ext):
        return dtype

Before:

Input Detected Correct
report.PDF text_file pdf_file
data.CSV text_file csv
doc.DOCX text_file docx

After: All resolve correctly regardless of case.

This is a single-line change with no behavioral impact for already-correct lowercase paths.

AI-assisted: written with the help of an AI coding agent (OpenClaw/GlM-5.1).

Uppercase/mixed-case extensions (.PDF, .Docx, .CSV) were silently
misrouted to the text loader instead of the correct parser, causing
binary content to be embedded into the RAG store.

Lowercase the path before matching against the extension map so that
Report.PDF resolves to PDF_FILE, data.CSV to CSV, etc.

Closes crewAIInc#6399
@coderabbitai

coderabbitai Bot commented Jul 8, 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: 49924e1d-0d8b-4a3d-a3a6-a3a1fe13abb7

📥 Commits

Reviewing files that changed from the base of the PR and between 289686a and 2a11d43.

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

📝 Walkthrough

Walkthrough

The get_file_type() function in data_types.py now lowercases the input path before matching file extensions, making extension detection case-insensitive for both filesystem paths and URLs.

Changes

Extension matching fix

Layer / File(s) Summary
Case-insensitive extension detection
lib/crewai-tools/src/crewai_tools/rag/data_types.py
get_file_type() lowercases the path before checking endswith against extension mapping keys, fixing misclassification of uppercase/mixed-case extensions.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: making RAG file-type detection case-insensitive.
Description check ✅ Passed The description directly explains the bug, the fix, and the expected behavior, matching the changeset.
Linked Issues check ✅ Passed The code change lowercases the path before extension matching, satisfying the linked issue's case-insensitive detection requirement.
Out of Scope Changes check ✅ Passed The PR appears narrowly scoped to the file-type detection fix and introduces no unrelated changes.
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

2 participants