Skip to content

fix(crewai-files): replace bare raises with PermanentUploadError in get_uploader - #6841

Open
jpcj223 wants to merge 2 commits into
crewAIInc:mainfrom
jpcj223:fix/bare-raise-in-uploader-factory
Open

fix(crewai-files): replace bare raises with PermanentUploadError in get_uploader#6841
jpcj223 wants to merge 2 commits into
crewAIInc:mainfrom
jpcj223:fix/bare-raise-in-uploader-factory

Conversation

@jpcj223

@jpcj223 jpcj223 commented Aug 6, 2026

Copy link
Copy Markdown

Problem

Bare raise statements in get_uploader() are used outside of except blocks, which causes a confusing RuntimeError: No active exception to re-raise instead of a meaningful error message.

Two affected locations:

  1. When an unsupported provider is passed (line 216)
  2. When bedrock provider is used without S3 bucket config (line 199)

Solution

Replace both bare raise statements with PermanentUploadError so users get a clear, actionable error message.

Changes

  • lib/crewai-files/src/crewai_files/uploaders/factory.py:
    • Import PermanentUploadError from crewai_files.processing.exceptions
    • Replace bare raise for unsupported provider with PermanentUploadError listing supported providers
    • Replace bare raise for unconfigured bedrock with PermanentUploadError explaining how to configure
  • lib/crewai-files/tests/test_uploader_factory.py:
    • Add unit tests for get_uploader() covering all supported providers and error paths

Testing

All 7 new tests pass:

…et_uploader

Bare raise statements outside of except blocks cause RuntimeError with a confusing 'No active exception to re-raise' message.

- Replace bare raise for unsupported provider with PermanentUploadError

- Replace bare raise for unconfigured bedrock with PermanentUploadError

- Add unit tests for factory function and error paths
@coderabbitai

coderabbitai Bot commented Aug 6, 2026

Copy link
Copy Markdown

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: 38aa8956-6dda-4040-b6af-c3200c2257bd

📥 Commits

Reviewing files that changed from the base of the PR and between 3d5ff84 and b26a87a.

📒 Files selected for processing (2)
  • lib/crewai-files/src/crewai_files/uploaders/factory.py
  • lib/crewai-files/tests/test_uploader_factory.py
🚧 Files skipped from review as they are similar to previous changes (1)
  • lib/crewai-files/src/crewai_files/uploaders/factory.py

📝 Walkthrough

Walkthrough

The uploader factory now raises explicit PermanentUploadError messages for missing Bedrock configuration and unsupported providers. Tests cover supported providers, error cases, Bedrock configuration sources, and optional boto3 availability.

Changes

Uploader factory behavior

Layer / File(s) Summary
Factory errors and validation
lib/crewai-files/src/crewai_files/uploaders/factory.py, lib/crewai-files/tests/test_uploader_factory.py
The factory reports Bedrock configuration requirements and unsupported providers through PermanentUploadError. Tests cover supported providers, invalid configurations, environment and keyword configuration, and conditional Bedrock test skips.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the main change: replacing bare raises with PermanentUploadError in get_uploader.
Description check ✅ Passed The description accurately explains the bare-raise problem, the PermanentUploadError solution, affected files, and added tests.
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.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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

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 `@lib/crewai-files/src/crewai_files/uploaders/factory.py`:
- Around line 200-204: Update the Bedrock uploader configuration validation in
get_uploader to reject bucket_name when it is None or otherwise empty, not
merely when the key is absent, so the actionable PermanentUploadError is raised
for missing bucket configuration. Add a regression test covering
get_uploader("bedrock", bucket_name=None).
🪄 Autofix

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 Plus

Run ID: 120bff8f-fa24-4e3b-8b4e-3bf585b43e7f

📥 Commits

Reviewing files that changed from the base of the PR and between 18c52c4 and 3d5ff84.

📒 Files selected for processing (2)
  • lib/crewai-files/src/crewai_files/uploaders/factory.py
  • lib/crewai-files/tests/test_uploader_factory.py

Comment thread lib/crewai-files/src/crewai_files/uploaders/factory.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant