fix: reorder notification DELETE routes so bulk clear matches first

FastAPI matches routes in declaration order. The DELETE /notifications
endpoint (bulk clear) was registered AFTER DELETE /notifications/{id},
so the path parameter route intercepted all requests to the bulk route,
causing a 422 UUID validation error instead of hitting clear_all.

Moved clear_all_notifications above dismiss_notification in the router.
Added regression test to verify route order.

Quality gates: pytest (22 passed)
This commit is contained in:
Alex Blank
2026-05-29 16:54:01 +02:00
parent 5f499ec1b0
commit 3d1f8d9cf7
4 changed files with 51 additions and 17 deletions
@@ -351,8 +351,12 @@ async def test_dismiss_all_affects_only_caller(
cleared = await notification_service.dismiss_all(db_session, user_a.id)
assert cleared == 3
items_a, total_a = await notification_service.list_notifications(db_session, user_a.id)
items_b, total_b = await notification_service.list_notifications(db_session, user_b.id)
items_a, total_a = await notification_service.list_notifications(
db_session, user_a.id
)
items_b, total_b = await notification_service.list_notifications(
db_session, user_b.id
)
assert total_a == 0
assert total_b == 2