Skip to content

Commit 75db3bf

Browse files
committed
fix(rolling-update): reject empty-key DEFAULT_EXTRA_ENV entries
- Codex P2 (rolling-update.sh:944, new angle over round 3): the prior validator only rejected entries without any equals sign; an entry like =1800MiB satisfied the *=* match and was let through, only to be rejected later by run_container key regex. Fail the merge explicitly for empty-key entries at the same point we fail on missing equals sign, so a malformed safeguard is caught with a clear message. The round-3 Gemini Medium about read -a / set -e was verified against bash 3.2 (macOS default): the existing [[ -n "$user" ]] guard prevents the empty-here-string case and whitespace-only input reads successfully into an empty array under bash 3.2. Not changing the || true shape the reviewer suggested; the guard is sufficient and appending || true would swallow real read failures.
1 parent 941ed32 commit 75db3bf

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

scripts/rolling-update.sh

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -938,12 +938,21 @@ merge_extra_env() {
938938
# is baked into deploy.env — a malformed token there means a
939939
# safeguard we installed deliberately is silently ignored. Fail
940940
# loudly instead of dropping it.
941+
# Three failure modes to catch early:
942+
# - no `=` at all (e.g. GOMEMLIMIT) -> malformed
943+
# - empty key before `=` (e.g. =1800MiB) -> malformed
944+
# (the `*=*` pattern match alone accepts this)
945+
# - empty pair (covered by the continue above)
941946
for pair in "${default_pairs[@]}"; do
942947
[[ -n "$pair" ]] || continue
943948
if [[ "$pair" != *=* ]]; then
944949
echo "rolling-update: malformed DEFAULT_EXTRA_ENV entry '$pair' (expected KEY=VALUE)" >&2
945950
return 1
946951
fi
952+
if [[ "${pair%%=*}" == "" ]]; then
953+
echo "rolling-update: malformed DEFAULT_EXTRA_ENV entry '$pair' (empty key)" >&2
954+
return 1
955+
fi
947956
done
948957
fi
949958
for pair in "${default_pairs[@]}"; do

0 commit comments

Comments
 (0)