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 <noreply@anthropic.com>
This commit is contained in:
2026-09-20 18:47:29 +02:00
parent fc90cf9a5f
commit 4d70c8950d
13 changed files with 22 additions and 22 deletions
+1 -1
View File
@@ -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.
+1 -1
View File
@@ -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),
+1 -1
View File
@@ -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)
+1 -1
View File
@@ -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)
+2 -2
View File
@@ -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
+2 -2
View File
@@ -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)
+2 -2
View File
@@ -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)
@@ -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)
+2 -2
View File
@@ -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)
@@ -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)
+3 -3
View File
@@ -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
+1 -1
View File
@@ -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)
+3 -3
View File
@@ -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