-
Notifications
You must be signed in to change notification settings - Fork 660
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Backup not found returns 404 instead of 400 #5479
Conversation
📝 WalkthroughWalkthroughThe changes introduced in this pull request involve the addition of a new exception class, Changes
Sequence Diagram(s)sequenceDiagram
participant Client
participant API
participant BackupService
Client->>API: Request backup
API->>BackupService: Check if backup exists
alt Backup not found
BackupService-->>API: Backup not found
API-->>Client: 404 Not Found (APINotFound)
else Backup found
BackupService-->>API: Backup data
API-->>Client: 200 OK (Backup data)
end
📜 Recent review detailsConfiguration used: CodeRabbit UI 📒 Files selected for processing (3)
🧰 Additional context used📓 Path-based instructions (1)supervisor/exceptions.py (6)Pattern
Pattern
Pattern Pattern Pattern Pattern 🔇 Additional comments (4)supervisor/exceptions.py (1)
The exception class follows the established pattern and uses the correct HTTP status code for resource not found scenarios. supervisor/api/backups.py (2)
The APINotFound import is appropriately grouped with related exception imports.
The error message "Backup does not exist" clearly indicates the nature of the error, and using APINotFound will correctly return a 404 status code. tests/api/test_backups.py (1)
The test effectively covers all endpoints that should return 404 when a backup is not found, using parametrization to reduce code duplication. Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
Proposed change
If a resource cannot be found, the API should return a 404 not a 400. Fixes this for backups.
Type of change
Additional information
Checklist
ruff format supervisor tests
)If API endpoints or add-on configuration are added/changed:
Summary by CodeRabbit
New Features
APINotFound
, for more specific error handling when a backup is not found.Bug Fixes
Tests