fix(variables): drop the key from the draft map before writing it

A rejected update left its key in vars, so the second pass picked it up
as a new variable and resent the stored key — the exact call the sparse
update is meant to avoid for keys that predate the identifier rule.
This commit is contained in:
Levi van Noort committed 2026-08-12 12:28:58 +02:00
1 parent 1d4cfad9fa
commit 0feeb2a627
1 file changed
+5 -1
@@ -152,6 +152,11 @@
editableVariables.map(async (variable) => {
const newValue = vars[variable.key] ?? null;
// Claim the key up front. A rejected write must not leave it
// behind for the second pass, which would retry it as a new
// variable and send the stored key along with it.
delete vars[variable.key];
if (newValue === null) {
await sdkDeleteVariable(variable.$id);
} else if (newValue !== variable.value) {
@@ -159,7 +164,6 @@
// the API keep the stored one.
await sdkUpdateVariable(variable.$id, undefined, newValue, false);
}
delete vars[variable.key];
})
);