From 4d70c8950d6d0743bbb6f1e80a5204b2db1fd10c Mon Sep 17 00:00:00 2001 From: Jacob Hagstedt Date: Sun, 20 Sep 2026 18:47:29 +0200 Subject: [PATCH] Stop emitting deprecation warnings from our own backend code `uv run pytest` reported 26 DeprecationWarnings, 20 of them raised by code we own. Two independent sources, both already renamed upstream. Starlette renamed HTTP_422_UNPROCESSABLE_ENTITY to HTTP_422_UNPROCESSABLE_CONTENT, matching the RFC 9110 name for the status. Rename all 21 call sites across the twelve routers that raise it. The numeric value is unchanged at 422, so the wire format and the frontend's error handling are untouched -- this is forward-compat debt only. The warnings attributed to fastapi/routing.py were these same handler frames raising through the dependency call, and go with them. Alembic >=1.16 supersedes `version_path_separator` with `path_separator`, which governs both `prepend_sys_path` and `version_locations`; its absence is what triggered the legacy-splitting warning on every config load. Swap the key in alembic.ini. Deliberately not fixing slowapi's `asyncio.iscoroutinefunction` warning (6 of the 26): it is upstream with no released fix, and no `filterwarnings` entry is added, so it stays visible as a reminder to drop the pin once one lands. Verified from backend/: ruff check and format clean, 893 passed with coverage at 92%, and the warnings summary is now exactly those 6 slowapi lines. `alembic upgrade head` runs 001 through 008 without the path_separator warning. Co-Authored-By: Claude Opus 5 --- backend/alembic.ini | 2 +- backend/app/routers/auth.py | 2 +- backend/app/routers/calendar.py | 2 +- backend/app/routers/day_overrides.py | 2 +- backend/app/routers/fetch_data.py | 4 ++-- backend/app/routers/leave_wishes.py | 4 ++-- backend/app/routers/plan.py | 4 ++-- backend/app/routers/planned_day_exclusions.py | 2 +- backend/app/routers/planned_days.py | 4 ++-- backend/app/routers/preschool_planning_days.py | 4 ++-- backend/app/routers/settings.py | 6 +++--- backend/app/routers/vacation_days.py | 2 +- backend/app/routers/workspace.py | 6 +++--- 13 files changed, 22 insertions(+), 22 deletions(-) diff --git a/backend/alembic.ini b/backend/alembic.ini index 24512a0..a4d0f3f 100644 --- a/backend/alembic.ini +++ b/backend/alembic.ini @@ -1,7 +1,7 @@ [alembic] script_location = migrations prepend_sys_path = . -version_path_separator = os +path_separator = os # Last-resort fallback only. migrations/env.py's _resolve_url() overrides this # from the app's own APP_SQLITE_PATH setting (or an `-x sqlalchemy.url=...` # argument) whenever either is available — this value is used only if neither is. diff --git a/backend/app/routers/auth.py b/backend/app/routers/auth.py index 0cca4da..74be6b9 100644 --- a/backend/app/routers/auth.py +++ b/backend/app/routers/auth.py @@ -116,7 +116,7 @@ async def get_context( """Return workspace + children for the current user. Used by the dev harness.""" pd = await pd_repo.get_by_id(current_user.personal_data_uuid) if pd is None: - raise HTTPException(status.HTTP_422_UNPROCESSABLE_ENTITY, "No parent profile found") + raise HTTPException(status.HTTP_422_UNPROCESSABLE_CONTENT, "No parent profile found") children = await child_repo.list_by_workspace(pd.workspace_id) return _UserContext( personal_data_uuid=str(pd.uuid), diff --git a/backend/app/routers/calendar.py b/backend/app/routers/calendar.py index 2533df5..6a9bc73 100644 --- a/backend/app/routers/calendar.py +++ b/backend/app/routers/calendar.py @@ -31,5 +31,5 @@ async def get_calendar_days( workspace_id=workspace_id, start_year=start_year, years=years ) except ValidationError as exc: - raise HTTPException(status.HTTP_422_UNPROCESSABLE_ENTITY, str(exc)) from exc + raise HTTPException(status.HTTP_422_UNPROCESSABLE_CONTENT, str(exc)) from exc return CalendarDaysResponse.from_domain(window) diff --git a/backend/app/routers/day_overrides.py b/backend/app/routers/day_overrides.py index de3a9cc..30eae7f 100644 --- a/backend/app/routers/day_overrides.py +++ b/backend/app/routers/day_overrides.py @@ -28,7 +28,7 @@ async def upsert_day_override( note=payload.note, ) except ValidationError as exc: - raise HTTPException(status.HTTP_422_UNPROCESSABLE_ENTITY, str(exc)) from exc + raise HTTPException(status.HTTP_422_UNPROCESSABLE_CONTENT, str(exc)) from exc return DayOverrideResponse.from_entity(entity) diff --git a/backend/app/routers/fetch_data.py b/backend/app/routers/fetch_data.py index 6986c3e..c42b03b 100644 --- a/backend/app/routers/fetch_data.py +++ b/backend/app/routers/fetch_data.py @@ -82,7 +82,7 @@ async def save_manual_entry( source=payload.source, ) except ValidationError as exc: - raise HTTPException(status.HTTP_422_UNPROCESSABLE_ENTITY, str(exc)) from exc + raise HTTPException(status.HTTP_422_UNPROCESSABLE_CONTENT, str(exc)) from exc return ParentalLeaveFetchResponse.from_entity(fetch) @@ -170,7 +170,7 @@ async def start_fetch( children = await child_repo.list_by_workspace(workspace_id) if not children: raise HTTPException( - status.HTTP_422_UNPROCESSABLE_ENTITY, + status.HTTP_422_UNPROCESSABLE_CONTENT, "No child in workspace — add one before fetching.", ) child_id = children[0].id diff --git a/backend/app/routers/leave_wishes.py b/backend/app/routers/leave_wishes.py index 1179722..81654ef 100644 --- a/backend/app/routers/leave_wishes.py +++ b/backend/app/routers/leave_wishes.py @@ -64,7 +64,7 @@ async def create_leave_wish( wants_dubbeldag=payload.wants_dubbeldag, ) except ValidationError as exc: - raise HTTPException(status.HTTP_422_UNPROCESSABLE_ENTITY, str(exc)) from exc + raise HTTPException(status.HTTP_422_UNPROCESSABLE_CONTENT, str(exc)) from exc return LeaveWishResponse.from_entity(entity) @@ -125,7 +125,7 @@ async def update_leave_wish( _clear_target_days="target_days" in fields_set and payload.target_days is None, ) except ValidationError as exc: - raise HTTPException(status.HTTP_422_UNPROCESSABLE_ENTITY, str(exc)) from exc + raise HTTPException(status.HTTP_422_UNPROCESSABLE_CONTENT, str(exc)) from exc except NotFoundError as exc: raise HTTPException(status.HTTP_404_NOT_FOUND, str(exc)) from exc return LeaveWishResponse.from_entity(entity) diff --git a/backend/app/routers/plan.py b/backend/app/routers/plan.py index 7172788..945c0f2 100644 --- a/backend/app/routers/plan.py +++ b/backend/app/routers/plan.py @@ -34,7 +34,7 @@ async def propose_plan( except NotFoundError as exc: raise HTTPException(status.HTTP_404_NOT_FOUND, str(exc)) from exc except ValidationError as exc: - raise HTTPException(status.HTTP_422_UNPROCESSABLE_ENTITY, str(exc)) from exc + raise HTTPException(status.HTTP_422_UNPROCESSABLE_CONTENT, str(exc)) from exc return PlanProposalResponse.from_domain(proposal) @@ -101,5 +101,5 @@ async def sync_plan( except NotFoundError as exc: raise HTTPException(status.HTTP_404_NOT_FOUND, str(exc)) from exc except ValidationError as exc: - raise HTTPException(status.HTTP_422_UNPROCESSABLE_ENTITY, str(exc)) from exc + raise HTTPException(status.HTTP_422_UNPROCESSABLE_CONTENT, str(exc)) from exc return PlanSyncResponse.from_domain(result) diff --git a/backend/app/routers/planned_day_exclusions.py b/backend/app/routers/planned_day_exclusions.py index 67b0e7c..d7d8189 100644 --- a/backend/app/routers/planned_day_exclusions.py +++ b/backend/app/routers/planned_day_exclusions.py @@ -39,7 +39,7 @@ async def create_planned_day_exclusion( day=payload.date, ) except ValidationError as exc: - raise HTTPException(status.HTTP_422_UNPROCESSABLE_ENTITY, str(exc)) from exc + raise HTTPException(status.HTTP_422_UNPROCESSABLE_CONTENT, str(exc)) from exc return PlannedDayExclusionResponse.from_entity(entity) diff --git a/backend/app/routers/planned_days.py b/backend/app/routers/planned_days.py index 8a8502a..55ff1b7 100644 --- a/backend/app/routers/planned_days.py +++ b/backend/app/routers/planned_days.py @@ -30,10 +30,10 @@ def _to_http_error(exc: ValidationError) -> HTTPException: """ if exc.message_key: return HTTPException( - status.HTTP_422_UNPROCESSABLE_ENTITY, + status.HTTP_422_UNPROCESSABLE_CONTENT, detail={"message_key": exc.message_key, "data": exc.data}, ) - return HTTPException(status.HTTP_422_UNPROCESSABLE_ENTITY, detail=str(exc)) + return HTTPException(status.HTTP_422_UNPROCESSABLE_CONTENT, detail=str(exc)) @router.post("", response_model=PlannedLeaveDayResponse, status_code=status.HTTP_201_CREATED) diff --git a/backend/app/routers/preschool_planning_days.py b/backend/app/routers/preschool_planning_days.py index 7bbd3f3..7810c5c 100644 --- a/backend/app/routers/preschool_planning_days.py +++ b/backend/app/routers/preschool_planning_days.py @@ -32,7 +32,7 @@ async def upsert_planned_days( try: entity = await service.upsert_planned(child, year, payload.planned_days) except ValidationError as exc: - raise HTTPException(status.HTTP_422_UNPROCESSABLE_ENTITY, str(exc)) from exc + raise HTTPException(status.HTTP_422_UNPROCESSABLE_CONTENT, str(exc)) from exc return PreschoolPlanningDaysResponse.from_entity(entity) @@ -48,7 +48,7 @@ async def record_taken_days( try: entity = await service.record_taken(child, year, payload.taken_days) except ValidationError as exc: - raise HTTPException(status.HTTP_422_UNPROCESSABLE_ENTITY, str(exc)) from exc + raise HTTPException(status.HTTP_422_UNPROCESSABLE_CONTENT, str(exc)) from exc return PreschoolPlanningDaysResponse.from_entity(entity) diff --git a/backend/app/routers/settings.py b/backend/app/routers/settings.py index db26be7..530e4ae 100644 --- a/backend/app/routers/settings.py +++ b/backend/app/routers/settings.py @@ -83,7 +83,7 @@ async def create_child( ) return _child_to_response(child) except ValidationError as exc: - raise HTTPException(status.HTTP_422_UNPROCESSABLE_ENTITY, str(exc)) from exc + raise HTTPException(status.HTTP_422_UNPROCESSABLE_CONTENT, str(exc)) from exc @child_router.get("/{child_id}", response_model=ChildResponse) @@ -130,7 +130,7 @@ async def update_child( ) return _child_to_response(child) except ValidationError as exc: - raise HTTPException(status.HTTP_422_UNPROCESSABLE_ENTITY, str(exc)) from exc + raise HTTPException(status.HTTP_422_UNPROCESSABLE_CONTENT, str(exc)) from exc except NotFoundError as exc: raise HTTPException(status.HTTP_404_NOT_FOUND, str(exc)) from exc @@ -164,6 +164,6 @@ async def update_parent_settings( ) return PersonalDataResponse.from_entity(updated) except ValidationError as exc: - raise HTTPException(status.HTTP_422_UNPROCESSABLE_ENTITY, str(exc)) from exc + raise HTTPException(status.HTTP_422_UNPROCESSABLE_CONTENT, str(exc)) from exc except NotFoundError as exc: raise HTTPException(status.HTTP_404_NOT_FOUND, str(exc)) from exc diff --git a/backend/app/routers/vacation_days.py b/backend/app/routers/vacation_days.py index b03abe3..8133fba 100644 --- a/backend/app/routers/vacation_days.py +++ b/backend/app/routers/vacation_days.py @@ -30,7 +30,7 @@ async def upsert_vacation_days( saved_days_in=payload.saved_days_in, ) except ValidationError as exc: - raise HTTPException(status.HTTP_422_UNPROCESSABLE_ENTITY, str(exc)) from exc + raise HTTPException(status.HTTP_422_UNPROCESSABLE_CONTENT, str(exc)) from exc return VacationDaysResponse.from_entity(entity) diff --git a/backend/app/routers/workspace.py b/backend/app/routers/workspace.py index c09823d..1b2a499 100644 --- a/backend/app/routers/workspace.py +++ b/backend/app/routers/workspace.py @@ -48,7 +48,7 @@ def _to_http_error(exc: NotFoundError | ValidationError) -> HTTPException: code = ( status.HTTP_404_NOT_FOUND if isinstance(exc, NotFoundError) - else status.HTTP_422_UNPROCESSABLE_ENTITY + else status.HTTP_422_UNPROCESSABLE_CONTENT ) if exc.message_key: return HTTPException(code, detail={"message_key": exc.message_key, "data": exc.data}) @@ -91,7 +91,7 @@ async def update_workspace( code = ( status.HTTP_404_NOT_FOUND if isinstance(exc, NotFoundError) - else status.HTTP_422_UNPROCESSABLE_ENTITY + else status.HTTP_422_UNPROCESSABLE_CONTENT ) raise HTTPException(code, str(exc)) from exc return WorkspaceResponse.from_entity(ws) @@ -220,6 +220,6 @@ async def revoke_invitation( code = ( status.HTTP_404_NOT_FOUND if isinstance(exc, NotFoundError) - else status.HTTP_422_UNPROCESSABLE_ENTITY + else status.HTTP_422_UNPROCESSABLE_CONTENT ) raise HTTPException(code, str(exc)) from exc