Skip to content

Commit a035558

Browse files
CassioMGclaude
andcommitted
fix(e2e): cap the attempt bound so oversized values cannot loop forever
The positive-integer regex still accepted digit strings beyond bash's 64-bit range, and `[ "$attempt" -ge 999999999999999999999999 ]` fails with "integer expression expected" exactly like a non-numeric value — falsy inside the `if`, so the bounded loop never exits. Same runaway, different route past the guard. Bound representability in the regex (1..999999, comfortably inside the integer range) and apply a 10-attempt cap numerically. Values above the cap clamp to it; only malformed input falls back to 1. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
1 parent d2e6524 commit a035558

1 file changed

Lines changed: 15 additions & 6 deletions

File tree

‎scripts/run-e2e-tests.sh‎

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -556,13 +556,22 @@ record_flaky_flow() {
556556
# maestro.log — the flake stays diagnosable after the job goes green.
557557
FLOW_ATTEMPTS="${E2E_FLOW_ATTEMPTS:-1}"
558558

559-
# The loop bound is compared with `-ge`. A non-numeric or zero value makes that
560-
# test error out and evaluate false on every pass, so the "bounded" retry loop
561-
# would never exit and would keep re-running the flow until the job times out.
562-
# Reject anything that is not a positive integer rather than trusting the env.
563-
if ! printf '%s' "$FLOW_ATTEMPTS" | grep -qE '^[1-9][0-9]*$'; then
564-
echo "⚠️ E2E_FLOW_ATTEMPTS='$FLOW_ATTEMPTS' is not a positive integer — using 1"
559+
# The loop bound is compared with `-ge`. Any value that comparison cannot
560+
# evaluate — non-numeric, or a number past bash's 64-bit integer range — makes
561+
# it error out and return false on every pass, so the "bounded" retry loop would
562+
# never exit and would keep re-running the flow until the job times out. Zero and
563+
# negatives bound nothing either. So validate rather than trusting the env: the
564+
# regex accepts 1..999999, which is comfortably inside the range where the
565+
# numeric comparison below is meaningful, and that comparison applies the cap.
566+
# Anything longer or non-numeric is malformed rather than merely too big, so it
567+
# falls back to 1 instead of being clamped.
568+
FLOW_ATTEMPTS_MAX=10
569+
if ! printf '%s' "$FLOW_ATTEMPTS" | grep -qE '^[1-9][0-9]{0,5}$'; then
570+
echo "⚠️ E2E_FLOW_ATTEMPTS='$FLOW_ATTEMPTS' is not an integer in 1..$FLOW_ATTEMPTS_MAX — using 1"
565571
FLOW_ATTEMPTS=1
572+
elif [ "$FLOW_ATTEMPTS" -gt "$FLOW_ATTEMPTS_MAX" ]; then
573+
echo "⚠️ E2E_FLOW_ATTEMPTS=$FLOW_ATTEMPTS exceeds the $FLOW_ATTEMPTS_MAX-attempt cap — using $FLOW_ATTEMPTS_MAX"
574+
FLOW_ATTEMPTS="$FLOW_ATTEMPTS_MAX"
566575
fi
567576

568577
# "device offline" is an ADB hiccup rather than a signal about the app, so it

0 commit comments

Comments
 (0)