From 7b94affecc417405a619287a8fd2d07811e144ac Mon Sep 17 00:00:00 2001 From: alejandrorpascual Date: Tue, 20 Oct 2026 12:13:00 -0400 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20[fix]=20card:=20refuse=20a=20mal?= =?UTF-8?q?formed=20issue=20before=20any=20GitHub=20read?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - move, status and item-id exit 64 unless the issue is one positive integer - before, "26 53" reached a strict GraphQL read, failed 3 retries and halted the run - cause: zsh does not word-split `set -- $pair`, so a two-card loop passed both numbers as one - tests/test-card.sh case 10: five bad values per verb exit 64 with no gh call and no halt file --- scripts/super-board-card.sh | 14 +++++++++++--- tests/test-card.sh | 15 +++++++++++++++ 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/scripts/super-board-card.sh b/scripts/super-board-card.sh index f11ea170..f3abf4cc 100755 --- a/scripts/super-board-card.sh +++ b/scripts/super-board-card.sh @@ -201,10 +201,18 @@ items() { # whole board, gh item-list shape, ~1 point per 100 cards || { echo "board read incomplete" >&2; return 69; } } +# The reads above run strict, so anything GitHub rejects halts the whole run. +# A malformed issue is the caller's mistake, not GitHub's: refuse it here (64). +# zsh does not word-split `set -- $pair`, which once passed "26 53" as one issue. +issue_arg() { # $1 = issue + [[ "$1" =~ ^[1-9][0-9]*$ ]] && return 0 + echo "invalid issue: '$1' — pass one issue number per call" >&2; exit 64 +} + case "$VERB" in - move) [ $# -eq 2 ] || { echo "usage: move " >&2; exit 64; }; move "$1" "$2" ;; - status) [ $# -eq 1 ] || { echo "usage: status " >&2; exit 64; }; read_card "$1"; echo "$STATUS_NAME" ;; - item-id) [ $# -eq 1 ] || { echo "usage: item-id " >&2; exit 64; }; item_id "$1"; echo "$ITEM_ID" ;; + move) [ $# -eq 2 ] || { echo "usage: move " >&2; exit 64; }; issue_arg "$1"; move "$1" "$2" ;; + status) [ $# -eq 1 ] || { echo "usage: status " >&2; exit 64; }; issue_arg "$1"; read_card "$1"; echo "$STATUS_NAME" ;; + item-id) [ $# -eq 1 ] || { echo "usage: item-id " >&2; exit 64; }; issue_arg "$1"; item_id "$1"; echo "$ITEM_ID" ;; ids) load_ids; jq -n --arg p "$PROJECT_ID" --arg f "$FIELD_ID" --argjson o "$OPTIONS_JSON" '{projectId:$p, fieldId:$f, options:$o}' ;; items) items ;; *) echo "unknown verb: $VERB" >&2; exit 64 ;; diff --git a/tests/test-card.sh b/tests/test-card.sh index 17e5340e..0ff586bc 100644 --- a/tests/test-card.sh +++ b/tests/test-card.sh @@ -112,4 +112,19 @@ RC=0; card items >/dev/null 2>&1 || RC=$? [ "$RC" != 0 ] || fail "incomplete board read must fail" ok "incomplete board read refused" +# 10 — a card number that is not one positive integer is a usage error (64): +# no GitHub call, no halt file. zsh does not word-split `$pair`, so +# `set -- $pair` once passed "26 53" here and halted a whole run (3 retries). +for bad in "26 53" "#26" "abc" "0" ""; do + for verb in status item-id; do + reset_log; rm -f "$TMP/halt.json"; RC=0; card $verb "$bad" >/dev/null 2>&1 || RC=$? + [ "$RC" = 64 ] || fail "$verb '$bad' should exit 64 (rc=$RC)" + [ ! -s "$FAKE_LOG" ] || fail "$verb '$bad' must not call gh: $(cat "$FAKE_LOG")" + [ ! -e "$TMP/halt.json" ] || fail "$verb '$bad' must not write a halt file" + done + reset_log; RC=0; card move "$bad" QA >/dev/null 2>&1 || RC=$? + [ "$RC" = 64 ] && [ ! -s "$FAKE_LOG" ] || fail "move '$bad' should exit 64 with no gh call (rc=$RC)" +done +ok "bad card number → 64, no GitHub call, no halt" + echo "PASS: $pass card-helper checks"