refactor(occupancy): replace manual 404 checks with domain_errors and clean delete result contract #251

Open
opened 2026-10-03 09:11:57 +00:00 by gabogg · 0 comments
Owner

Follow-up for PR #177 (next-day settings activation, #114) addressing pass-4 review finding P3-4:

Scope

In app/controllers/occupancy_controller.py:340-346 and :364-370, manual error status checks inspect res.status == "NOT_FOUND" to raise HTTPException, while app/controllers/errors.py:domain_errors already maps LookupError to 404 with standard JSON format and headers.
Additionally, "NOT_FOUND" leaks into the ScheduleExceptionDeleteResult contract.

Acceptance Criteria

  • Raise LookupError in service methods when entities are not found.
  • Replace manual controller 404 blocks with with domain_errors():.
  • Remove NOT_FOUND status leakage from ScheduleExceptionDeleteResult.

Refs #177, #114.

Follow-up for PR #177 (next-day settings activation, #114) addressing pass-4 review finding P3-4: ### Scope In `app/controllers/occupancy_controller.py:340-346` and `:364-370`, manual error status checks inspect `res.status == "NOT_FOUND"` to raise `HTTPException`, while `app/controllers/errors.py:domain_errors` already maps `LookupError` to 404 with standard JSON format and headers. Additionally, `"NOT_FOUND"` leaks into the `ScheduleExceptionDeleteResult` contract. ### Acceptance Criteria - Raise `LookupError` in service methods when entities are not found. - Replace manual controller 404 blocks with `with domain_errors():`. - Remove `NOT_FOUND` status leakage from `ScheduleExceptionDeleteResult`. Refs #177, #114.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gabogg/hikcentral#251
No description provided.