Skip to content

fix(parser): match the .eml extension in any case - #20090

Merged
yuzhichang merged 1 commit into
infiniflow:0.27.xfrom
devYRPauli:fix/eml-extension-case
Sep 30, 2026
Merged

yuzhichang merged 1 commit into
infiniflow:0.27.xfrom
devYRPauli:fix/eml-extension-case

Conversation

@devYRPauli

@devYRPauli devYRPauli commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

The pipeline email parser fails on an .eml file whose extension is not lower case. A file named MESSAGE.EML or Mail.Eml produces no email content.

Parser._email compares the extension with ".eml" case-sensitively (rag/flow/parser/parser.py:1270). Any other spelling goes to the .msg branch. That branch passes the RFC 5322 bytes to extract_msg.Message, which expects an Outlook OLE2 file.

The upper-case name does reach _email. filename_type lowercases the name before it matches eml (api/utils/file_utils.py:55). The pipeline dispatch lowercases the suffix before it selects the email setup (rag/flow/parser/parser.py:1445), then passes the original name to _email. On main, the Go email parser lowercases the extension before it selects the .msg branch (internal/parser/parser/email_parser.go:89).

Measured on 0.27.x (1a730e34e) with the same .eml bytes under different names:

name before after
message.eml (control) parses unchanged
MESSAGE.EML, short message FileNotFoundError from olefile, which reads the bytes as a path subject and body parse
Mail.Eml, short message FileNotFoundError subject and body parse
MESSAGE.EML, 4249-byte message extract_msg.exceptions.InvalidFileFormatError: not an OLE2 structured storage file subject and body parse

The change lowercases the extension before the comparison. ext has no other use in _email.

Test: test_eml_extension_matches_in_any_case in test/unit_test/rag/flow/parser/test_email_attachments.py. It parses one .eml under the names MESSAGE.EML and Mail.Eml, and checks the subject and the body. With the fix reverted, both cases fail:

FAILED test_email_attachments.py::test_eml_extension_matches_in_any_case[MESSAGE.EML] - FileNotFoundError: [Errno 2] No such file or directory: b'From: sender@exam...
FAILED test_email_attachments.py::test_eml_extension_matches_in_any_case[Mail.Eml] - FileNotFoundError: [Errno 2] No such file or directory: b'From: sender@exam...

With the fix, the whole module passes (11 passed). ruff check and ruff format --check pass on both changed files.

@coderabbitai

coderabbitai Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Navigate logical layers of code changes, visualize relationships, and explore their blast radius.

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: e1843162-6b40-4e0f-8489-efe5c527e818

📥 Commits

Reviewing files that changed from the base of the PR and between 893fc78 and e296844.

📒 Files selected for processing (2)
  • rag/flow/parser/parser.py
  • test/unit_test/rag/flow/parser/test_email_attachments.py

Included review availability: Your plan provides up to 10 included reviews per hour; 9 remain after this review.


📝 Walkthrough

Walkthrough

The .eml extension check is now case-insensitive. Tests verify that uppercase and mixed-case .eml filenames preserve the parsed subject and body.

Changes

EML extension handling

Layer / File(s) Summary
Case-insensitive routing and tests
rag/flow/parser/parser.py, test/unit_test/rag/flow/parser/test_email_attachments.py
The parser lowercases the extension before checking for .eml. Tests cover uppercase and mixed-case filenames and verify the parsed subject and body.

Priority: ⬇️ Low

Estimated code review effort: 1 (Trivial) | ~5 minutes

Change: Bug fix

Suggested reviewers: jessyancoding

Merge Risk: ⚪ Minimal · up to e2968

Uppercase and mixed-case .eml filenames are handled by the email parser. No actionable merge risk remains after normal checks.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 80.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 5 functions across 2 files.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly and concisely describes the main change: case-insensitive matching for the .eml extension in the parser.
Description check ✅ Passed The description includes the required Summary section and clearly explains the problem, root cause, implementation, test coverage, and validation results.

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

A rabbit checks the suffix with care,
“.EML can travel there!”
The subject lands, the body too,
Mixed-case names now make it through,
Then hops away with ears held high.

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

@xugangqiang xugangqiang added the ci Continue Integration label Sep 24, 2026
@xugangqiang

Copy link
Copy Markdown
Contributor

@devYRPauli pls help to check if go side has this issue as well.

@devYRPauli

Copy link
Copy Markdown
Contributor Author

The Go side does not have this issue. Every Go path lowercases the extension or the file type before it compares it:

  • internal/parser/parser/email_parser.go:89: ext := strings.ToLower(filepath.Ext(filename))
  • internal/utility/file.go: GetFileType lowercases the suffix.
  • internal/service/document/document_parser_selection.go:33 lowercases the file name.
  • internal/ingestion/component/parser_dispatch.go:159: fileTypeFromInputs lowercases file_type.

I also ran EmailParser on main (313ca90) with the same message saved as message.eml, MESSAGE.EML and Message.Eml. All three parse with no error, and the JSON output is the same as for the lowercase name.

The red ragflow_preflight job fails in test/unit_test/deepdoc/vision/test_ocr_rotate_crop_limit.py, which this PR does not touch. #20185 fixed that test on main after this run.

@xugangqiang

Copy link
Copy Markdown
Contributor

LGTM.

@devYRPauli pls rebase from latest code to resolve ci issue. Thank you.

@devYRPauli

Copy link
Copy Markdown
Contributor Author

Main removed rag/flow/parser/parser.py with the rest of the Python server in #20289. A rebase onto main leaves this PR with no diff. The Go parser already matches .eml in any case, as measured in my comment above.

The file still exists on 0.27.x. Should I retarget this PR to 0.27.x, or close it?

@xugangqiang

Copy link
Copy Markdown
Contributor

@devYRPauli I guess python & golang are splitted. Golang goes to 1.0 (RC) and python goes to 0.27.XXX.

Parser._email compared the extension with ".eml" case-sensitively. A
file named MESSAGE.EML or Mail.Eml went to the .msg branch, and
extract_msg.Message failed on the RFC 5322 bytes: FileNotFoundError for
a short message, InvalidFileFormatError for a 4 KB one.

Upload type detection and the pipeline suffix dispatch already lowercase
the name, and the Go email parser lowercases the extension. Lowercase it
here too.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@devYRPauli
devYRPauli changed the base branch from main to 0.27.x September 29, 2026 15:47
@devYRPauli
devYRPauli force-pushed the fix/eml-extension-case branch from e296844 to c56ccde Compare September 29, 2026 15:48
@devYRPauli

Copy link
Copy Markdown
Contributor Author

Retargeted to 0.27.x and rebased onto 0.27.x (1a730e34e). The commit applies with no conflict.

test_email_attachments.py gives 11 passed. With the fix reverted, the 2 new cases fail with FileNotFoundError. test_ocr_rotate_crop_limit.py failed in the earlier CI run. It gives 5 passed on 0.27.x.

@codecov

codecov Bot commented Sep 29, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 38.01%. Comparing base (a70e038) to head (c56ccde).
⚠️ Report is 3 commits behind head on 0.27.x.

Additional details and impacted files
@@           Coverage Diff           @@
##           0.27.x   #20090   +/-   ##
=======================================
  Coverage   38.01%   38.01%           
=======================================
  Files          54       54           
  Lines       15511    15511           
  Branches      125      125           
=======================================
  Hits         5896     5896           
  Misses       9587     9587           
  Partials       28       28           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@yuzhichang
yuzhichang merged commit 9221608 into infiniflow:0.27.x Sep 30, 2026
4 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ci Continue Integration

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants