fix: reorder validation check and add saved fields to service config response

The validation error check was placed before the config save operation, causing early returns that skipped persisting valid fields. This moves the error check after saving valid values and adds a "saved" key to the response listing which fields were successfully stored. Also adds autocomplete and password manager attributes to the password input field in the service config form to prevent browser autofill interference.
This commit is contained in:
2026-06-12 19:28:54 +00:00
parent 9003cf6570
commit 370f833d09
3 changed files with 9 additions and 8 deletions
+5 -4
View File
@@ -68,12 +68,13 @@ class ServiceManager:
valid[field.key] = field.to_storage(field.coerce(raw))
except ValueError as e:
errors[field.key] = str(e)
if errors:
return {"ok": False, "errors": errors}
for key, value in valid.items():
set_setting(key, value)
logger.info(f"Service {name} config saved ({len(valid)} fields)")
return {"ok": True, "errors": {}}
if valid:
logger.info(f"Service {name} config saved ({len(valid)} fields)")
if errors:
return {"ok": False, "errors": errors, "saved": list(valid.keys())}
return {"ok": True, "errors": {}, "saved": list(valid.keys())}
def supervise(self) -> None:
for svc in self._services.values():