fix(variables): filter valueless entries before validating an import

An entry with an empty value is discarded rather than written, so an
invalid key on one of them was rejecting the whole file and taking the
valid variables down with it.
This commit is contained in:
Levi van Noort committed 2026-08-13 08:50:46 +02:00
1 parent 0feeb2a627
commit e10ae018bf
1 file changed
+6 -6
@@ -36,7 +36,9 @@
if (!Object.keys(uploaded).length) {
throw new Error('No variables found');
}
const entries = Object.entries(uploaded);
// Drop the valueless entries first. They are never written, so an
// invalid key on one of them must not reject the whole file.
const entries = Object.entries(uploaded).filter(([, value]) => !!value);
const validationError = validateVariables(
entries.map(([key, value]) => ({ key, value }))
@@ -45,11 +47,9 @@
throw new Error(validationError);
}
entries
.filter(([, value]) => !!value)
.forEach(([key, value]) => {
variables.push({ key, value, secret });
});
entries.forEach(([key, value]) => {
variables.push({ key, value, secret });
});
show = false;
} catch (e) {