fix(settings): honor explicit null on nullable fields, ignore on the rest

Routes were calling model_dump(exclude_none=True), which drops every
client-sent null before it reaches the service. The service then layered
on its own `if value is not None` guard. Net effect: setting a nullable
column back to null was a no-op — the MCPPage default-voice picker sends
null when the user picks "no default" and the row was silently keeping
whatever was there before.

Switched the routes to exclude_unset=True so absent fields stay absent
but explicit nulls survive the dump, and centralised the per-field
nullability check in the service. The check inspects the SQLAlchemy
column metadata so non-nullable columns (stt_model, llm_model, the chord
key lists) still drop nulls instead of crashing the request, while
default_playback_voice_id can finally be cleared.
This commit is contained in:
Jamie Pine
2026-04-24 20:36:48 -07:00
parent 5f62a0ed1b
commit 800e390108
2 changed files with 22 additions and 8 deletions
+2 -2
View File
@@ -20,7 +20,7 @@ async def update_capture_settings_endpoint(
patch: models.CaptureSettingsUpdate,
db: Session = Depends(get_db),
):
return settings_service.update_capture_settings(db, patch.model_dump(exclude_none=True))
return settings_service.update_capture_settings(db, patch.model_dump(exclude_unset=True))
@router.get("/generation", response_model=models.GenerationSettingsResponse)
@@ -33,4 +33,4 @@ async def update_generation_settings_endpoint(
patch: models.GenerationSettingsUpdate,
db: Session = Depends(get_db),
):
return settings_service.update_generation_settings(db, patch.model_dump(exclude_none=True))
return settings_service.update_generation_settings(db, patch.model_dump(exclude_unset=True))