Skip to content

fix: classify .wmf files as VISUAL instead of OTHER - #15822

Merged
JinHai-CN merged 2 commits into
infiniflow:mainfrom
devYRPauli:fix/wmf-filetype-uppercase
Aug 25, 2026
Merged

JinHai-CN merged 2 commits into
infiniflow:mainfrom
devYRPauli:fix/wmf-filetype-uppercase

Conversation

@devYRPauli

Copy link
Copy Markdown
Contributor

What

filename_type() classifies .wmf files as OTHER instead of VISUAL.

filename_type first calls _normalize_filename_for_type, which lowercases the name (base.lower()), and then matches against the extension patterns. But the VISUAL pattern lists WMF in uppercase:

r".*\.(jpg|jpeg|png|...|eps|ai|raw|WMF|webp|avif|...)$"

Since the candidate is always lowercased before matching, the WMF alternative can never match any casing of a .wmf file. Every other extension in the same alternation is lowercase, so this is a typo. WMF (a vector/image format, commonly extracted from Office documents) therefore falls through to OTHER and bypasses the picture/image parser that the VISUAL type routes to (FileService.get_parser, and the VISUAL branches in document handling).

Fix

Lowercase the one extension so it matches: WMF -> wmf.

Tests

Added ("pic.wmf", VISUAL) and ("pic.WMF", VISUAL) to the existing test_valid_filenames parametrization in test/unit_test/api/utils/test_api_file_utils.py. Both fail before the change (return OTHER) and pass after. Verified the real filename_type directly: .wmf/.WMF go from other to visual, while existing controls (x.png, movie.mp4) stay visual. ruff check clean.

@coderabbitai

coderabbitai Bot commented Jun 8, 2026 •

Copy link
Copy Markdown
Contributor

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: 3264cf04-a7fa-4486-a3d3-e4c1220ea2c9

📥 Commits

Reviewing files that changed from the base of the PR and between 4b6346b and 2e8e7cc.

📒 Files selected for processing (2)
  • api/utils/file_utils.py
  • test/unit_test/api/utils/test_api_file_utils.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • test/unit_test/api/utils/test_api_file_utils.py
  • api/utils/file_utils.py

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


📝 Walkthrough

Walkthrough

This PR updates filename_type to classify WMF extensions as visual files after filename normalization. It adds tests for .wmf and .WMF.

Changes

File extension type detection

Layer / File(s) Summary
WMF extension case-insensitive classification
api/utils/file_utils.py, test/unit_test/api/utils/test_api_file_utils.py
The visual extension regex now matches wmf. Tests verify that .wmf and .WMF map to FileType.VISUAL.

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

Merge Risk: ⚪ Minimal · up to 2e8e7

This localized fix correctly routes WMF files to the visual-file handling path and adds regression coverage for both common casing variants; no actionable merge-blocking risk remains beyond normal checks and review.

Poem

The rabbit checks WMF files today,
Lowercase and uppercase pass the way.
The pattern now agrees,
Tests confirm with ease,
Visual files hop into play.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the primary change: classifying .wmf files as VISUAL instead of OTHER.
Description check ✅ Passed The description provides the problem, technical cause, fix, affected behavior, tests, and verification results. It does not use the exact template heading "### Summary", but it is otherwise complete a…
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 1 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.
Full details: Description check

Explanation

The description provides the problem, technical cause, fix, affected behavior, tests, and verification results. It does not use the exact template heading "### Summary", but it is otherwise complete and directly related to the pull request.


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.

@dosubot dosubot Bot added size:XS This PR changes 0-9 lines, ignoring generated files. 🐞 bug Something isn't working, pull request that fix bug. 🧪 test Pull requests that update test cases. labels Jun 8, 2026
@devYRPauli
devYRPauli force-pushed the fix/wmf-filetype-uppercase branch from cd1db20 to 4dab471 Compare July 16, 2026 15:53
filename_type lowercases the filename via _normalize_filename_for_type
before matching, but the VISUAL extension pattern listed wmf in uppercase
(WMF). Since the candidate is always lowercased, the WMF alternative was
unreachable and .wmf files fell through to OTHER, so they bypassed the
image/picture parser that the VISUAL type routes to. Every other
extension in the alternation is lowercase. Change WMF to wmf.

Signed-off-by: Yash Raj Pandey <[email protected]>
@devYRPauli
devYRPauli force-pushed the fix/wmf-filetype-uppercase branch from 4dab471 to 6622127 Compare August 19, 2026 16:47
@coderabbitai

coderabbitai Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@devYRPauli

Copy link
Copy Markdown
Contributor Author

Rebased onto current main to clear the conflict. The PR is mergeable again.

The conflict was on the same line as the fix. #17830 added bmp to the VISUAL pattern while this branch lowercased WMF. I kept the bmp addition and applied the lowercase change on top, so the line now carries both.

I re-checked the behaviour against current main by running the real filename_type and _normalize_filename_for_type from both trees:

input current main this PR
pic.wmf other visual
pic.WMF other visual
diagram.WMF other visual
photo.png visual visual
photo.bmp visual visual
notes.txt doc doc

The photo.bmp row confirms the entry from #17830 still works after the rebase.

1 commit, 2 files, +3/-1.

@devYRPauli

Copy link
Copy Markdown
Contributor Author

@JinHai-CN could you assign a reviewer here as well? This one also has none.

I rebased it on 19 August to clear the conflict with #17830. The line now carries both the bmp entry from that PR and the lowercase wmf fix. The PR is mergeable.

@JinHai-CN JinHai-CN added the ci Continue Integration label Aug 25, 2026
@coderabbitai

coderabbitai Bot commented Aug 25, 2026

Copy link
Copy Markdown
Contributor

Note

GitHub couldn't provide a complete incremental comparison for this pull request, so CodeRabbit is performing a full review instead. This review may take a little longer.

@codecov

codecov Bot commented Aug 25, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.65%. Comparing base (7cb4e30) to head (2e8e7cc).
⚠️ Report is 12 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15822      +/-   ##
==========================================
- Coverage   94.56%   90.65%   -3.91%     
==========================================
  Files          10       10              
  Lines         717      717              
  Branches      118      118              
==========================================
- Hits          678      650      -28     
- Misses         25       39      +14     
- Partials       14       28      +14     

☔ 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.

@JinHai-CN
JinHai-CN merged commit 71413c9 into infiniflow:main Aug 25, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

🐞 bug Something isn't working, pull request that fix bug. ci Continue Integration size:XS This PR changes 0-9 lines, ignoring generated files. 🧪 test Pull requests that update test cases.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants