fix(tools): make rag file extension detection case-insensitive#6514
Open
ALDRIN121 wants to merge 1 commit into
Open
fix(tools): make rag file extension detection case-insensitive#6514ALDRIN121 wants to merge 1 commit into
ALDRIN121 wants to merge 1 commit into
Conversation
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
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthrough
ChangesRAG file detection
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
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. Comment |
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.
Summary
Fixes #6399
DataTypes.from_content()inlib/crewai-tools/src/crewai_tools/rag/data_types.pymatched 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
get_file_type()(one-line fix)tests/rag/test_data_types.pywith regression coverage: 12 parametrized file-extension cases (lower/upper/mixed case) plus URL detection casesVerification
main(7 failures — exactly the uppercase/mixed-case inputs) and pass with the fix (14/14)tests/rag/+tests/tools/rag/suite: 176 passedruff check,ruff format, strictmypy, and pre-commit hooks all passreport.PDFtext_filepdf_filedata.CSVtext_filecsvdoc.DOCXtext_filedocxhttps://example.com/file.PDFwebsitepdf_file