Skip to content

fix(github): the commit-status read fails closed when the runner raises, and check_verdict no longer swallows StopIteration from under-scripted test mocks #1350

Closed

Description

@dan-petty

Problem

#769 made check_verdict the single fail-closed reader of a pull request's checks. One of its criteria: "A statuses read that cannot be read blocks and names the reason (unread_reason)". The commit-status read has one path that breaks this. If the runner raises StopIteration or IndexError, the read returns no statuses and an empty reason, and the verdict is computed from check runs alone [code: src/devops_cli/github/check_verdict.py:353-356]. Checked at bbc644b, the head of release/v0.2.28. The clause came in with #769 and is not on main.

try:
    res = runner(status_cmd, check=False, quiet=True)
except StopIteration, IndexError:
    return [], None, ""
  • The read fails open. In a probe, the first call returned one successful check run. For the second call (statuses):

    • a non-zero exit gave unread_reason='GitHub commit status API error: …', which blocks;
    • IndexError or StopIteration gave unread_reason='' and a passing verdict [measured: probe at bbc644b].

    The check-runs read has no such clause [code: src/devops_cli/github/check_verdict.py:327].

  • It is a test shim. Without the clause, three tests fail [measured: pytest with the clause removed, 3 failed / 271 passed]:

    • test_fetch_pr_check_verdicts_rest_fallback_on_cli_failure [code: tests/test_pr_check_verdict.py:202];
    • test_rest_pagination_slurp_bucket_count_matches_total_count [code: tests/test_pr_check_verdict.py:318];
    • TestPrCommands::test_pr_checks_fallback_on_gh_failure [code: tests/test_pr_cmd.py:892].

    Each scripts a MagicMock(side_effect=[...]) list that has no /status response. The mock runs out and raises StopIteration, and the production code swallows it. A test that forgets the status call therefore passes as if the head had no statuses.

  • Reach. Every production caller passes run_gh [code: src/devops_cli/commands/pr.py:352, :403, :1040, :1292; src/devops_cli/github/pr_monitor.py:441; src/devops_cli/roadmap/run.py:362]. run_gh does not raise either exception for this argv [code: src/devops_cli/github/rate_limiter.py:1893]. The fail-open is latent: only a test double reaches it today. If a future change made run_gh raise IndexError, readiness would pass while a status context fails.

Acceptance criteria

  • _fetch_commit_statuses_from_rest has no try/except around the runner call. An exception from the runner propagates, exactly as it does from the check-runs read, and rg -n "except StopIteration" src/devops_cli/github prints nothing.
  • The three tests above script the /status response, so each runs every call it makes and asserts on statuses as well as check runs.
  • A scripted test: check runs pass and the status read raises. fetch_pr_check_verdicts does not return a passing verdict.
  • changelog.d/<n>.md records the change under ### Fixed. CHANGELOG.md and docs/ROADMAP.md are not edited.
  • uv run devops ci passes.

Strategic alignment

Activity

  1. added
    scope/github
    priority/p3-low
    on Oct 7, 2026
  2. dan-petty-bot commented on Oct 7, 2026

    @dan-petty-bot
    Collaborator

    Intake placed this item to the backlog: at intake only a critical fix goes into a release; a release start pulls Ready items in, P0 features first.

    • Priority: P3-Low. The fail-open is latent—no production caller can trigger it today, only a test double reaches it, and the candidate's own review rates verified severity as low.
    • Value: Medium. It undermines the fail-closed guarantee and lets three tests pass incorrectly, but no user-facing misbehaviour is reachable in production at present.
    • Effort: Low. The fix is removing one try/except block and updating three existing tests to script the /status response.
  3. added this to the v0.2.38 milestone on Oct 20, 2026
  4. dan-petty commented on Oct 21, 2026

    @dan-petty
    OwnerAuthor

    What changed

    #1766, merged into release/v0.2.38 as acb3569.

    Fixes #1350

    5 file(s) changed.

    How it was verified

    Check runs at 1f4fda2:

    • Prune PR DevContainer Images: pass
    • Audit Defect PR Hardening: skipping
    • devops-cli: pass
    • zizmor: pass
    • bandit: pass
    • CodeQL: pass
    • Rule Pack Tests: pass
    • Fail-to-Pass Self-Check: pass
    • Changed-Test Independence: pass
    • Tests & Coverage: pass
    • Analyze (python): pass
    • Fail-to-Pass Check: pass
    • Analyze (actions): pass
    • Static Analysis: pass
    • DevContainer Image: skipping
    • Service Image: skipping
    • Dependency Freshness: skipping

    Acceptance Criteria of docs/agent/tasks/task-1350-commit-status-fail-closed.md:

    No Acceptance Criteria section.

  5. added
    type/bug
    and removed on Oct 30, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority/p3-lowscope/githubtype/bug

    Type

    No type

    Projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions