ci(known-failures): close four fail-open / false-positive paths (CIP-3488)#401
Conversation
…3488) The known-failure gate could report success while verifying nothing, or fail with the wrong reason. Four independent defects, all raised in review on #389 and still live on main: - T14 (fail-open): the registry parser was fully anchored and hardcoded `u64`; any deviation (u32, indentation, a trailing comment, `1_000`) parsed zero rows, printed "nothing to verify", and exit 0. Now the strict parse is tolerant of indentation / trailing comments / `_` digit separators, and a declared-vs-parsed mismatch (counted independently with a loose matcher) is a hard error (exit 2). - T3 (transient reads as missing): switched from `gh issue view … || echo MISSING` to `gh api repos/<repo>/issues/<n>`, classifying a genuine `(HTTP 404)` as NOT_FOUND and every other gh/network error as a distinct transient ERROR, so a network blip no longer masquerades as "issue missing". - T15 (PR numbers pass as issues): the REST issues object carries a `pull_request` key iff the number is a PR; PR numbers are now rejected instead of validating as open issues. - T16 (bash 3.2): replaced `mapfile` (bash 4+) with a 3.2-safe while-read loop — mise invokes this as `bash …` and stock macOS /bin/bash is 3.2. Verified end-to-end against the live registry and crafted fixtures (u32 drift → exit 2; PR #399 → rejected; missing #99999999 → NOT_FOUND; `3_87` + indentation + comment → parsed 387, OPEN), and under /bin/bash 3.2.57.
📝 WalkthroughWalkthroughThe known-failure verification script now uses strict Bash 3.2-compatible marker parsing and REST-based classification of issue targets, with distinct handling for pull requests, missing issues, and verification errors. ChangesKnown failure verification
Estimated code review effort: 3 (Moderate) | ~20 minutes Sequence Diagram(s)sequenceDiagram
participant KnownFailuresScript
participant GitHubRESTAPI
participant TestReferences
KnownFailuresScript->>KnownFailuresScript: Parse known_failure markers
KnownFailuresScript->>GitHubRESTAPI: Query issue number
GitHubRESTAPI-->>KnownFailuresScript: Return classification
KnownFailuresScript->>TestReferences: Check marker references
TestReferences-->>KnownFailuresScript: Return reference status
KnownFailuresScript-->>KnownFailuresScript: Emit diagnostics and exit status
Suggested reviewers: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
tasks/test/known-failures.sh (1)
83-114: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueDeclare function variables as
localto prevent accidental scope leakage.Although
classify_numberis currently safely executed inside a subshell (result=$(classify_number "$number")), preventing its variable assignments from polluting the global scope, it doesn't explicitly declare its variables aslocal.If this script is ever refactored to call the function directly in the current shell, it will silently overwrite the main loop's
$numbervariable and leak$err_file,$out,$state, and$errglobally. Consider scoping these variables locally as a defensive measure.Note: When making this change, be careful to keep
local outseparate from theif out=$(...); thenassignment. Combininglocal out=$(...)directly in anifcondition masks the exit code of the command substitution in bash.💡 Proposed defensive refactor
classify_number() { - number="$1" - err_file=$(mktemp) + local number="$1" + local err_file out state is_pr err + + err_file=$(mktemp) # On HTTP 200 the bundled `--jq` prints "<state>\t<is_pr>"; on any HTTP/network🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tasks/test/known-failures.sh` around lines 83 - 114, Update classify_number to declare number, err_file, out, state, is_pr, and err as local variables near the start of the function. Keep local out separate from the if out=$(gh api ...); then condition so gh’s exit status remains the condition being evaluated.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@tasks/test/known-failures.sh`:
- Around line 83-114: Update classify_number to declare number, err_file, out,
state, is_pr, and err as local variables near the start of the function. Keep
local out separate from the if out=$(gh api ...); then condition so gh’s exit
status remains the condition being evaluated.
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: eb77241b-e59a-4246-89d9-c5a1ad694e0a
📒 Files selected for processing (1)
tasks/test/known-failures.sh
Closes CIP-3488.
tasks/test/known-failures.sh— the CI gate #389 introduced — had four independent defects that let it pass a broken state. All four were raised in review on #389, none addressed before merge, all still live onmain. This gate exists to stop known-failure registrations from silently rotting, but in its current form it can report success while doing nothing at all — the exact failure mode it was built to prevent.Fixes
u64: any deviation (u32, indentation, a trailing comment,1_000) parsed zero rows, printed "nothing to verify", andexit 0. Now: the strictpub const ISSUE_<NAME>: u64 = <n>;parse tolerates indentation / trailing line comments /_digit separators, and the declaration count is taken independently with a loose matcher — a declared-vs-parsed mismatch is a hard error (exit 2), so format drift can never silently skip a marker.gh issue view … 2>/dev/null || echo "MISSING"(which conflated 5xx / rate-limit / auth / DNS with a real 404) withgh api repos/<repo>/issues/<n>: a genuine(HTTP 404)classifies asNOT_FOUND, everything else as a distinct transientERRORwith a "re-run the gate" hint. A network blip no longer red-lightsci-requiredunder the wrong message.gh issue viewresolves both. The REST issues object carries apull_requestkey iff the number is a PR, so PR numbers are now rejected instead of validating as open issues.mapfile(bash 4+) with a bash 3.2-safewhile readloop —mise.tomlinvokes this asbash tasks/test/known-failures.shand stock macOS/bin/bashis 3.2.(T2, the
set -euo pipefaildead-code branch, was already fixed onmainvia a|| trueguard — not included.)Verification
Tested end-to-end against the live registry and crafted fixtures:
OPEN, gate OKu32drift (declared 1, parsed 0)ISSUE_*NOT_FOUND— "does not exist"3_87+ indentation +// commentAlso confirmed clean under stock
/bin/bash3.2.57 (T16). CI-only change, no changeset (per CLAUDE.md exclusions).Summary by CodeRabbit