fix(api): propagate exception handlers to versioned apps#34
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests.
|
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
d6b74bd to
95066cb
Compare
|
Claude finished @olivermeyer's task in 2m 35s —— View job Code Review for PR #34OverviewThis PR unifies exception handler registration across root and versioned FastAPI apps. The implementation is sound and well-tested, but there are important considerations around the breaking change. ✅ Strengths
🚨 Blocking Issues1. Breaking Change Classification - The parameter Issue:
Impact: Any downstream code calling Fix options:
Note: The version bump is already 0.7.2 → 0.8.0 (MINOR), which is correct for semantic versioning pre-1.0 where MINOR can include breaking changes. 💡 Suggestions1. Type hint improvements - The code uses version_app.add_exception_handler( # type: ignore[arg-type]
exc_class_or_status_code=ApiException,
handler=api_exception_handler, # pyright: ignore[reportArgumentType]
)Suggestion: This likely indicates a signature mismatch. Consider:
2. Test naming consistency - Test name is verbose but clear: def test_init_api_propagates_custom_exception_handlers_to_versioned_appsConsider shorter but equally clear: def test_init_api_applies_custom_handlers_to_versioned_appsNot blocking - current name is fine, just slightly verbose 3. Documentation enhancement The docstring explains the "why" well, but could benefit from a migration example: """...existing docstring...
Migration note:
Prior to v0.8.0, versioned apps required a separate
``version_exception_handler_registrations`` parameter.
This is no longer needed; all handlers in
``exception_handler_registrations`` now apply to both
root and versioned apps automatically.
Before (v0.7.x)::
init_api(
exception_handler_registrations=[(MyError, handler)],
version_exception_handler_registrations=[(MyError, handler)],
versions=["v1"]
)
After (v0.8.0+)::
init_api(
exception_handler_registrations=[(MyError, handler)],
versions=["v1"]
)
"""4. Consider adding a CHANGELOG entry Document this breaking change: ### [0.8.0] - 2026-04-08
#### Changed
- **BREAKING**: Removed `version_exception_handler_registrations` parameter from `init_api()`.
All exception handlers (including custom ones) now propagate to versioned apps automatically.
Use `exception_handler_registrations` for all apps. (#34)🧪 Test QualityAll tests follow best practices:
📊 Metrics
RecommendationNear approval - The code quality and implementation are excellent. The main concern is the breaking change handling:
The technical implementation is sound and ready to merge once the breaking change is properly communicated. |
|



Deprecating
version_exception_handler_registrationssuch thatexception_handler_registrationsapplies to the root API instance and all versioned API instances, to match Bridge behaviour.