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"