fix: transactional env var save, empty key validation, frontend error handling
All checks were successful
Check / check (pull_request) Successful in 4s
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:
@@ -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.",
|
||||
);
|
||||
});
|
||||
},
|
||||
}));
|
||||
|
||||
|
||||
Reference in New Issue
Block a user