Conversation
…lobal error handler, regenerated openapi docs + frontend types
📝 WalkthroughWalkthroughRefactors backend error handling to use domain-specific exceptions (ConflictError, NotFoundError, ValidationError) and enriches OpenAPI response descriptions; updates generated frontend API types/SDK to match error-code/description changes. Changes
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
🧪 Generate unit tests (beta)
No actionable comments were generated in the recent review. 🎉 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
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (1)
docs/reference/openapi.json (1)
90-105:⚠️ Potential issue | 🟠 MajorAvoid account enumeration in registration errors.
The explicit “Username already registered” and “Email already registered” responses make it easier to probe account existence. Consider using a single, generic conflict response (and optionally a single status code) for public registration endpoints.
🔧 Suggested doc tweak for safer messaging
- "description": "Username already registered", + "description": "Registration failed", ... - "description": "Email already registered", + "description": "Registration failed",
🤖 Fix all issues with AI agents
In `@docs/reference/openapi.json`:
- Around line 299-306: Replace ownership-specific 403 responses that reveal
resource existence (e.g., responses with description "Not the owner of this
execution") with a generic authorization failure or 404 to reduce enumeration;
locate the OpenAPI response objects (the entries with description "Not the owner
of..." and their $ref to ErrorResponse) and change the description text to a
non-resource-specific message like "Access denied" or switch the response code
to 404 where appropriate, and apply the same change to the other occurrences
called out (lines covering the other response blocks at the ranges mentioned) so
all ownership-specific hints are masked consistently.
🧹 Nitpick comments (2)
backend/app/api/routes/auth.py (1)
248-266: Redundant "attempt" log after the operation already succeeded.Line 249 logs "Token verification attempt" but
get_current_useron line 248 has already completed successfully at that point. Consider changing the log message to just "Token verified" or removing the first log call to avoid the misleading "attempt" label followed immediately by "successful".backend/app/api/routes/admin/users.py (1)
157-161: Document 404 response for non-existent user deletion.The
delete_userendpoint only documents a 400 response for self-deletion. However,admin_user_service.delete_user→repository.delete_userraisesUserNotFoundErrorwhen the target user doesn't exist, which is mapped to a 404 response. Adding this to theresponsesparameter would complete the OpenAPI specification:responses={ 400: {"model": ErrorResponse, "description": "Cannot delete your own account"}, 404: {"model": ErrorResponse, "description": "User not found"}, }
|



Summary by cubic
Standardized API error handling by removing route-level try/catches and using domain exceptions handled by the global error handler. Updated OpenAPI, regenerated frontend SDK/types, and aligned tests with new status codes and messages.
Refactors
Migration
Written for commit b7a4025. Summary will update on new commits.
Summary by CodeRabbit
Documentation
Bug Fixes