fix: transactional env var save, empty key validation, frontend error handling
All checks were successful
Check / check (pull_request) Successful in 4s

- Wrap DELETE + INSERTs in a database transaction via new
  ReplaceEnvVarsByAppID() to prevent silent data loss on partial
  insert failure. Rollback on any error; return 500 instead of 200.
- Add server-side validation rejecting entries with empty keys
  (returns 400 with error message).
- Add frontend error handling for non-2xx responses with user-visible
  alert messages.
- Remove stale //nolint:dupl directives (files no longer duplicate).
This commit is contained in:
clawbot
2026-03-10 12:25:35 -07:00
parent df6aad9b21
commit 5a986aa8fd
4 changed files with 96 additions and 33 deletions

View File

@@ -73,11 +73,30 @@ document.addEventListener("alpine:init", () => {
body: JSON.stringify(
this.vars.map((e) => ({ key: e.key, value: e.value })),
),
}).then((res) => {
if (res.ok) {
window.location.reload();
}
});
})
.then((res) => {
if (res.ok) {
window.location.reload();
return;
}
res.json()
.then((data) => {
window.alert(
data.error ||
"Failed to save environment variables.",
);
})
.catch(() => {
window.alert(
"Failed to save environment variables.",
);
});
})
.catch(() => {
window.alert(
"Network error: could not save environment variables.",
);
});
},
}));