Skip to content

fix: allow .bmp uploads in filename type whitelist - #17830

Merged
JinHai-CN merged 1 commit into
infiniflow:mainfrom
hippozjs:fix/support-bmp-upload
Aug 19, 2026
Merged

JinHai-CN merged 1 commit into
infiniflow:mainfrom
hippozjs:fix/support-bmp-upload

Conversation

@hippozjs

@hippozjs hippozjs commented Aug 5, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Frontend Images already includes bmp (web/src/constants/common.ts), and picture parsing already accepts .bmp (internal/parser/parser/picture_parser.go, rag/app/picture.py via Pillow).
  • Upload still rejects .bmp because the gate functions omit it from the visual whitelist:
    • Python: api/utils/file_utils.py → filename_type()
    • Go: internal/utility/file.go → FilenameType() (used by document_upload.go)
  • Result: This type of file has not been supported yet! even for valid BMP files under size limits.
  • This PR adds bmp to both whitelist sites and a small Go unit test.

Why this is inconsistent

Surface .bmp
Frontend Images / preview supported
GetFileType() (Go) supported
Picture parser / MIME map supported
Upload filename_type / FilenameType rejected as OTHER

Test plan

  • go test ./internal/utility/ -run TestFilenameTypeBMP
  • Upload a small .bmp via dataset document API → success (type visual, parser picture)
  • Confirm .png / .jpg upload behavior unchanged
  • Confirm unsupported extensions (e.g. .exe) still rejected

Made with Cursor

@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. labels Aug 5, 2026
@coderabbitai

coderabbitai Bot commented Aug 5, 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: 513d08a2-5fe8-4e5d-802d-6a5a632c568f

📥 Commits

Reviewing files that changed from the base of the PR and between f41f866 and 228bfdb.

📒 Files selected for processing (3)
  • api/utils/file_utils.py
  • internal/utility/file.go
  • internal/utility/filename_type_test.go
🚧 Files skipped from review as they are similar to previous changes (3)
  • api/utils/file_utils.py
  • internal/utility/filename_type_test.go
  • internal/utility/file.go

📝 Walkthrough

Walkthrough

The PR adds .bmp to Python visual filename detection and .jpg to Go visual filename detection. It adds table-driven tests for BMP, uppercase, nested, PNG, and unsupported executable filenames.

Changes

Filename classification

Layer / File(s) Summary
Visual extensions and classification tests
api/utils/file_utils.py, internal/utility/file.go, internal/utility/filename_type_test.go
Visual filename detection recognizes .bmp in Python and .jpg in Go. The tests cover BMP, uppercase extensions, nested paths, PNG files, and unsupported executable files.

Estimated code review effort: 2 (Simple) | ~5 minutes

Poem

A rabbit checks each file with care,
BMP and JPG join the pair.
PNG files pass the gate,
Uppercase paths classify straight.
Unsupported files stay outside.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly and concisely describes the main change: allowing BMP uploads through the filename type whitelist.
Description check ✅ Passed The description includes the required Summary section, explains the problem and solution, and documents the test plan and remaining validation steps.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
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.

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick comments (1)
internal/utility/filename_type_test.go (1)

21-37: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Cover every newly accepted extension.

The implementation changes include .icon in api/utils/file_utils.py Line 76 and .jpg in internal/utility/file.go Line 160. This table tests .bmp, .png, and .exe, but not .icon or .jpg. Add direct cases for those extensions, or point to equivalent existing tests. Keep Python and Go classification coverage aligned.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@internal/utility/filename_type_test.go` around lines 21 - 37, Extend
TestFilenameTypeBMP’s cases to directly cover the newly accepted .icon and .jpg
extensions, expecting FileTypeVISUAL for both. Keep the existing BMP, PNG, and
EXE cases unchanged so Go classification coverage remains aligned with the
Python file extension changes.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@internal/utility/filename_type_test.go`:
- Around line 21-37: Extend TestFilenameTypeBMP’s cases to directly cover the
newly accepted .icon and .jpg extensions, expecting FileTypeVISUAL for both.
Keep the existing BMP, PNG, and EXE cases unchanged so Go classification
coverage remains aligned with the Python file extension changes.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro Plus

Run ID: fdecc66c-6a27-46e9-88dd-63fe917fced1

📥 Commits

Reviewing files that changed from the base of the PR and between f5cdd01 and c1a83bb.

📒 Files selected for processing (3)
  • api/utils/file_utils.py
  • internal/utility/file.go
  • internal/utility/filename_type_test.go

@JinHai-CN JinHai-CN added the ci Continue Integration label Aug 5, 2026
Frontend Images and picture parsers already treat bmp as visual, but
upload gates filename_type/FilenameType reject it as OTHER.

Co-authored-by: Cursor <[email protected]>
@hippozjs
hippozjs force-pushed the fix/support-bmp-upload branch from c1a83bb to 228bfdb Compare August 6, 2026 02:21
@hippozjs

hippozjs commented Aug 6, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up

Rebased onto latest main (228bfdb) — previously ~50 commits behind.

About the previous Python CI failures

ragflow_tests_* (python) failed before any BMP-related assertions ran. Root cause looks like CI tenant model setup against SiliconFlow, not this whitelist change:

  • Error in set_tenant_info: Critical error in add model instance SILICONFLOW/CI
  • embedding/rerank: account balance is insufficient (HTTP 402)
  • chat models: No valid response received

Go paths already passed (ragflow_tests_elasticsearch (go), ragflow_tests_infinity (go), ragflow_preflight).

This PR only adds bmp to:

  • api/utils/file_utils.py → filename_type()
  • internal/utility/file.go → FilenameType()
    plus a small Go unit test.

Picture parsing already accepts .bmp; the upload gate was the inconsistency.

CodeRabbit nit

The suggestion to add .icon / .jpg test cases appears to be a false positive — those extensions were already in the whitelist; only bmp was added.

Request

@JinHai-CN could you please re-trigger CI / take another look when convenient? Happy to re-run if the SiliconFlow CI credential issue is resolved on the runner side.

@coderabbitai

coderabbitai Bot commented Aug 6, 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 6, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 90.65%. Comparing base (f41f866) to head (228bfdb).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@           Coverage Diff           @@
##             main   #17830   +/-   ##
=======================================
  Coverage   90.65%   90.65%           
=======================================
  Files          10       10           
  Lines         717      717           
  Branches      118      118           
=======================================
  Hits          650      650           
  Misses         39       39           
  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.

@JinHai-CN
JinHai-CN merged commit d82c48e into infiniflow:main Aug 19, 2026
5 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants