fix: disabling sync via settings page no longer returns spurious error 400

This commit is contained in:
Mathieu Moran
2026-08-12 00:02:54 -04:00
parent 0fea9718bc
commit 79222c8bb5
3 changed files with 407 additions and 5 deletions
+6 -3
View File
@@ -33,12 +33,15 @@ def update_device_config(body, errors):
# Check if sync is enabled; if so, only allow sync-related updates
sync_enabled = _get_sync_enabled()
if sync_enabled:
# User cannot edit these fields if syncing from server
if any(k in body for k in ["owner_name", "car_model", "avatar_path"]):
errors["error"] = "Cannot edit device config while server sync is enabled. Server is source of truth."
# Allow toggling sync_enabled off
if "sync_enabled" in body and not body["sync_enabled"]:
_set_sync_enabled(False)
# Toggling off is always allowed — don't return error even if
# other locked fields are in the body (the JS always sends them).
return errors
# User cannot edit locked fields while syncing from server.
if any(k in body for k in ["owner_name", "car_model", "avatar_path"]):
errors["error"] = "Cannot edit device config while server sync is enabled. Server is source of truth."
return errors
# Not syncing: allow all edits