Skip to content

Commit 941ed32

Browse files
committed
fix(rolling-update): explicit IFS + fail loud on malformed DEFAULT_EXTRA_ENV
- Gemini Medium (lines 924, 934): set IFS=$' \t\n' per read -a call so the split is stable regardless of any surrounding IFS mutation. - Codex P2 (line 938): validate DEFAULT_EXTRA_ENV entries explicitly. Unlike user-supplied EXTRA_ENV (forgivable typo, silently dropped for compatibility with existing deploy.env habits), DEFAULT_EXTRA_ENV is where we install safeguards like GOMEMLIMIT; a typo there means the safeguard is silently absent. Fail the merge with a clear message instead.
1 parent edd2a91 commit 941ed32

1 file changed

Lines changed: 15 additions & 2 deletions

File tree

scripts/rolling-update.sh

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -920,8 +920,10 @@ merge_extra_env() {
920920
# empty here-string returns non-zero, which trips `set -e`. Skip the
921921
# read when the source string is empty — the empty array is the
922922
# intended result either way.
923+
# IFS is explicitly set per-read so a caller's surrounding IFS
924+
# doesn't change how DEFAULT_EXTRA_ENV / EXTRA_ENV are split.
923925
if [[ -n "$user" ]]; then
924-
read -r -a user_pairs <<< "$user"
926+
IFS=$' \t\n' read -r -a user_pairs <<< "$user"
925927
fi
926928
for pair in "${user_pairs[@]}"; do
927929
[[ -n "$pair" ]] || continue
@@ -931,7 +933,18 @@ merge_extra_env() {
931933
done
932934

933935
if [[ -n "$defaults" ]]; then
934-
read -r -a default_pairs <<< "$defaults"
936+
IFS=$' \t\n' read -r -a default_pairs <<< "$defaults"
937+
# Unlike EXTRA_ENV (user-supplied, forgivable typos), DEFAULT_EXTRA_ENV
938+
# is baked into deploy.env — a malformed token there means a
939+
# safeguard we installed deliberately is silently ignored. Fail
940+
# loudly instead of dropping it.
941+
for pair in "${default_pairs[@]}"; do
942+
[[ -n "$pair" ]] || continue
943+
if [[ "$pair" != *=* ]]; then
944+
echo "rolling-update: malformed DEFAULT_EXTRA_ENV entry '$pair' (expected KEY=VALUE)" >&2
945+
return 1
946+
fi
947+
done
935948
fi
936949
for pair in "${default_pairs[@]}"; do
937950
[[ -n "$pair" ]] || continue

0 commit comments

Comments
 (0)