Repository navigation
Fix: empty file with better message - #15232
Conversation
📝 WalkthroughWalkthroughThe ChangesStorage content validation in build_chunks
Estimated code review effort🎯 1 (Trivial) | ⏱️ ~2 minutes Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 3❌ Failed checks (2 warnings, 1 inconclusive)
✅ Passed checks (2 passed)
✏️ 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. Comment |
There was a problem hiding this comment.
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
📒 Files selected for processing (1)
rag/svr/task_executor.py
| if binary is None: | ||
| raise FileNotFoundError(f"File not found: storage returned no content for {bucket}/{name}.") |
There was a problem hiding this comment.
🛠️ 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 Report✅ All modified and coverable lines are covered by tests. 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. 🚀 New features to boost your workflow:
|
Fix: empty file with better message