Skip to content

Fix: empty file with better message - #15232

Merged
wangq8 merged 1 commit into
infiniflow:mainfrom
wangq8:bugfix/fix-empty-file
May 26, 2026
Merged

wangq8 merged 1 commit into
infiniflow:mainfrom
wangq8:bugfix/fix-empty-file

Conversation

@wangq8

@wangq8 wangq8 commented May 26, 2026

Copy link
Copy Markdown
Collaborator

Fix: empty file with better message

@coderabbitai

coderabbitai Bot commented May 26, 2026 •

Copy link
Copy Markdown
Contributor

Review Change Stack

📝 Walkthrough

Walkthrough

The build_chunks function in task_executor.py now validates that the document binary fetched from storage is not None. When the storage fetch returns None, the code explicitly raises FileNotFoundError, which is then caught by the existing exception handler to report the appropriate progress error before propagating the exception.

Changes

Storage content validation in build_chunks

Layer / File(s) Summary
Storage content None validation
rag/svr/task_executor.py
The build_chunks function explicitly checks if get_storage_binary(...) returns None and raises FileNotFoundError with a "File not found" message, allowing the existing error-handling path to report a progress error before propagating the exception.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~2 minutes

Poem

🐰 A file once lost, now found with care,
A simple guard, transparent and fair,
When storage returns but nothing's there,
We raise the alarm, the message's flare,
hop 🐇 — another bug's no longer rare!

🚥 Pre-merge checks | ✅ 2 | ❌ 3

❌ Failed checks (2 warnings, 1 inconclusive)

Check name Status Explanation Resolution
Description check ⚠️ Warning The pull request description only repeats the title and lacks required template sections like 'What problem does this PR solve?' and 'Type of change'. Complete the pull request description by filling out all required template sections including the problem statement and change type to help reviewers understand the purpose and impact.
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Fix: empty file with better message' is vague and doesn't clearly convey what specific issue is being fixed or which file/component is affected. Provide a more descriptive title that clearly identifies the specific issue (e.g., 'Add explicit FileNotFoundError validation in build_chunks' or 'Improve error handling for empty files in task executor').
✅ Passed checks (2 passed)
Check name Status Explanation
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.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.


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 and usage tips.

@wangq8 wangq8 added the ci Continue Integration label May 26, 2026
@wangq8
wangq8 marked this pull request as ready for review May 26, 2026 03:50
@dosubot dosubot Bot added the size:XS This PR changes 0-9 lines, ignoring generated files. label May 26, 2026

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

Actionable comments posted: 1

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

Inline comments:
In `@rag/svr/task_executor.py`:
- Around line 276-277: Add a log entry immediately before the FileNotFoundError
is raised in the binary-none branch so the missing-file event is visible in
logs: in the task_executor.py check where "if binary is None:" (using variables
bucket and name) call the module or class logger (e.g. logger.error or
self.logger.error consistent with surrounding code) to log a clear message like
"storage returned no content for {bucket}/{name}" including bucket/name and any
relevant context, then raise FileNotFoundError as before.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: fcf315e7-0fc7-4799-9b30-466503e1f4c5

📥 Commits

Reviewing files that changed from the base of the PR and between 0d2a172 and ad47a79.

📒 Files selected for processing (1)
  • rag/svr/task_executor.py

Comment thread rag/svr/task_executor.py
Comment on lines +276 to +277
if binary is None:
raise FileNotFoundError(f"File not found: storage returned no content for {bucket}/{name}.")

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.

🛠️ Refactor suggestion | 🟠 Major | ⚡ Quick win

Add logging for the new validation flow.

The new validation correctly checks for None and raises FileNotFoundError, which integrates well with the existing exception handler. However, per coding guidelines, new flows should include logging. Consider adding a log statement before raising the exception to aid debugging and operational visibility.

📝 Proposed addition
         binary = await get_storage_binary(bucket, name)
         if binary is None:
+            logging.warning(f"Storage returned None for {bucket}/{name}, file not found")
             raise FileNotFoundError(f"File not found: storage returned no content for {bucket}/{name}.")
         logging.info("From minio({}) {}/{}".format(timer() - st, task["location"], task["name"]))

As per coding guidelines, **/*.py: Add logging for new flows.

🤖 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 `@rag/svr/task_executor.py` around lines 276 - 277, Add a log entry immediately
before the FileNotFoundError is raised in the binary-none branch so the
missing-file event is visible in logs: in the task_executor.py check where "if
binary is None:" (using variables bucket and name) call the module or class
logger (e.g. logger.error or self.logger.error consistent with surrounding code)
to log a clear message like "storage returned no content for {bucket}/{name}"
including bucket/name and any relevant context, then raise FileNotFoundError as
before.

@codecov

codecov Bot commented May 26, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.16%. Comparing base (3dbd874) to head (ad47a79).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main   #15232      +/-   ##
==========================================
+ Coverage   93.12%   93.16%   +0.03%     
==========================================
  Files          10       10              
  Lines         713      717       +4     
  Branches      116      118       +2     
==========================================
+ Hits          664      668       +4     
  Misses         29       29              
  Partials       20       20              

☔ View full report in Codecov by Sentry.
📢 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.

@wangq8
wangq8 merged commit 619b971 into infiniflow:main May 26, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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.

1 participant