Skip to content

fix(github): pr monitor reports ready when a poll reads no check #4927

Closed

Description

@dan-petty

Bug Description

devops pr monitor <n> reported a pull request as ready while one of its checks had failed. The last poll read no check at all (Checks: 0/0 passed (0/0 done)), and the monitor took the empty list as success:

ℹ [427s] Checks: 25/27 passed (25/27 done)
ℹ [508s] Checks: 0/0 passed (0/0 done)
✓ PR #4916 is 100% READY FOR MERGING: All checks passed, reviews complete, 0 unresolved threads.

At that time the check run DevContainer Image of the head commit had the conclusion failure (27 check runs: 23 success, 3 skipped, 1 failure). The monitor exited with status 0.

Suspected cause: _judge_checks in src/devops_cli/github/merge_readiness.py returns with no blocker when head_sha is empty. get_pr_monitoring_status in src/devops_cli/github/pr_monitor.py sets head_sha to "" when the pull request read gives no head.sha. Then the verdict reads no check and has no blocker, and _settled_result reports the pull request as ready. A read that gives no check must fail closed, as CHECKS_UNREAD does for a failed check read.

Steps to Reproduce

  1. Open a pull request with a check that fails.
  2. Run devops pr monitor <n> --timeout 1800 while the GitHub API is slow.
  3. A poll reads the pull request with no head commit, or reads no check.
  4. See Checks: 0/0 passed and the ready message with exit status 0.

Expected Behavior

A poll that reads no head commit or no check is a poll with no data: the monitor says so and polls again, or fails closed. It never reports ready while a check of the head commit failed.

Existing Tool Considered

No new tool is needed. The fix is in the readiness verdict of devops_cli.github.merge_readiness.

Source: #4916

Alternatives check of 2026-11-15: none.
Tool: none found.

Proposed design

Problem statement

devops pr monitor reports a pull request ready when a poll reads no head commit or no check. _judge_checks returns with no blocker when the head SHA is empty, and an empty check list adds no blocker. The monitor then prints Checks: 0/0 passed and exits 0 while a check of the head commit failed. The fix makes both cases fail closed with a checks_unread blocker, as a failed check read already does.

Acceptance criteria

Requirement: Block on a poll with no head commit

assess_merge_readiness SHALL hold a checks_unread blocker when the pull request payload gives no head commit SHA.

Scenario: Payload with no head SHA

  • WHEN the payload of the pull request holds no head.sha
  • THEN MergeReadiness.kinds holds BlockerKind.CHECKS_UNREAD and MergeReadiness.is_ready is False

Requirement: Block on a check read that gives no check

assess_merge_readiness SHALL hold a checks_unread blocker when the read of the head commit gives no check and no unread reason.

Scenario: Head commit with an empty check read

  • WHEN the check read of the head commit returns zero items with no unread_reason
  • THEN MergeReadiness.blockers holds one text that starts with PR #<n> check verification failed closed:

Requirement: Keep a failing check as a blocker

assess_merge_readiness SHALL hold a checks_failing blocker when a check run of the head commit has the conclusion failure.

Scenario: One failing check run

  • WHEN the head commit holds a non-empty SHA and one check run in the FAIL bucket
  • THEN MergeReadiness.kinds holds BlockerKind.CHECKS_FAILING and MergeReadiness.is_ready is False

Requirement: Monitor reports a poll with no check data as not ready

The monitor SHALL report a poll that reads no head commit as not ready, with checks_failed set and exit code 1.

Scenario: Monitor poll with no head SHA

  • WHEN get_pr_monitoring_status reads a pull request payload with no head.sha
  • THEN the status holds checks_failed True and a non-empty blockers, and the settled result holds success False and exit_code 1

Existing Tool Considered

No open, maintained tool covers this need. The alternatives check of 2026-11-15 returned the verdict none and found no library that gives a merge-readiness verdict over the check runs of the head commit, or that fails closed on an empty read. The fix stays in the project's own devops_cli.github.merge_readiness. Written cost of that own code: about 20,000 tokens to build, keep and fix the guard and its tests, and about 1 hour of elapsed time.

Key questions

  • Why does the monitor report ready when a poll reads no check?: assess_merge_readiness builds head_sha from the head.sha of the payload, and _judge_checks returns with no blocker when it is empty. The verdict then holds no check and no blocker, so MergeReadiness.is_ready is True. [sources: src/devops_cli/github/merge_readiness.py:259, src/devops_cli/github/merge_readiness.py, src/devops_cli/github/pr_monitor.py:523]
  • Where must the fail-closed guard live?: Put the guard in _judge_checks. assess_merge_readiness is the one verdict that devops pr check-readiness, devops pr ready and devops pr monitor share, so each of them fails closed. (best practice) [sources: src/devops_cli/github/merge_readiness.py, src/devops_cli/github/pr_monitor.py:523]
    • Chosen: Guard in _judge_checks. Every caller of assess_merge_readiness gets the same fail-closed verdict.
    • Rejected: Guard in get_pr_monitoring_status. It fixes the monitor only, and devops pr ready keeps the fail-open path.
    • Rejected: Guard in _settled_result. The verdict still calls the pull request ready, and only the monitor changes.
  • Which blocker kind does an empty head SHA or an empty check read use?: Use BlockerKind.CHECKS_UNREAD, the kind a failed check read uses. CHECK_FAILURE_KINDS already holds it, so PRMonitorStatus.checks_failed is True and the monitor exits 1 with no other change. (best practice) [sources: src/devops_cli/github/merge_readiness.py:94, src/devops_cli/github/pr_monitor.py]
    • Chosen: BlockerKind.CHECKS_UNREAD. It already means a check read that gave no verdict, and each caller maps it to a failure.
    • Rejected: A new BlockerKind.CHECKS_EMPTY. Each caller maps blocker kinds to its own exit codes, so a new kind needs a mapping in each caller.
    • Rejected: BlockerKind.CHECKS_FAILING. No check failed in this case: the poll read no check.
  • Does a poll that reads no check fail closed or poll again?: Fail closed. The poll gives the checks_unread blocker and the monitor exits 1. A pull request with no check data is not merge ready. (best practice) [sources: docs/adr/0004-ci-is-the-authoritative-gate.md, src/devops_cli/github/pr_monitor.py:587]
    • Chosen: Fail closed with checks_unread. ADR 0004 refuses a merge with missing CI runs, so a poll with no check data is not ready.
    • Rejected: Poll again until the timeout. The poll loop has no marker that tells a read with no data from a read with no checks, so the loop can run to the timeout.
    • Rejected: Report ready. That is the defect.
  • Which test files cover the guard?: Add the verdict cases to tests/github/test_merge_readiness.py and the monitor case to tests/github/test_pr_monitor_empty_checks.py. [sources: tests/github/test_merge_readiness.py, tests/github/test_pr_monitor_empty_checks.py, tests/github/test_github_pr_monitor.py]

Fit

Fits in one pull request.

Suspected block

None.

Dependencies

None.

Activity

  1. added
    source/agent
    type/bug
    scope/github
    status/new
    value/high
    effort/low
    on Nov 12, 2026
  2. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    Intake placed this item to the backlog: intake puts every new item in the backlog. A person plans the milestones.

    • Type: type/bug. The fix prefix of the title gives the type.
    • Scope: scope/github. The (github) scope of the title gives the scope.
    • Priority: P1-High. The monitor can report a PR as ready while a check on the head commit has failed, which defeats the tool's core purpose.
    • Value: High. A false ready verdict can cause a merge with failing checks, removing the safety the monitor exists to provide.
    • Effort: Low. The fix is a guard in one function, _judge_checks, to fail closed when head_sha is empty, as the body already identifies the location.
    • Related: refactor(github): read a pull request's checks once, fail-closed, for wait, monitor and readiness #769, which asks for a different change. Both address the monitor treating absent checks as success, but #769 fixes a failed API read while the candidate fixes an empty head_sha that skips the check read entirely.
  3. added
    priority/p1-high
    on Nov 12, 2026
  4. added
    priority/p2-medium
    and removed
    priority/p1-high
    on Nov 12, 2026
  5. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    One more occurrence on 2026-11-12: devops pr monitor 4952 --timeout 1800 printed [92s] Checks: 30/31 passed (30/31 done), then [176s] Checks: 0/0 passed (0/0 done), and then reported the pull request ready. The check runs API for the head commit, read after it, gave 27 success and 5 skipped, so the outcome was correct this time. The ready line still came from a poll that read no check.

  6. devops-cli-service commented on Nov 15, 2026

    @devops-cli-service
    Contributor

    Alternatives check: none

    Reason: The searches for a tool that monitors pull-request check runs with a fail-closed readiness verdict returned only unrelated documentation pages, and no open, maintained library covers that verdict. The issue itself asks for no tool: the fix is a guard in the project's own _judge_checks/_settled_result so an empty head SHA or an empty check list fails closed.

    Tool: none found

    Lacks:

    • No searched tool supplies a merge-readiness verdict over GitHub check runs of the head commit
    • No searched tool fails closed when a poll reads no head commit or no check
    • The reported defect is in the project's own devops_cli.github.merge_readiness and pr_monitor code, which an outside tool does not replace

    Searches run:

    • tool monitor pull request checks fail closed merge readiness CLI, results: 5
    • github merge queue required status checks tool library python check runs verdict, results: 5
    • "pr monitor" CLI tool github wait for checks pass, results: 5
    • merge-readiness github check runs python library "check runs" conclusion failure fail closed, results: 5
    • prow tide merge automation github checks, results: 5
    • gh pr checks wait required status checks github CLI extension, results: 5
    • "merge readiness" tool open source pull request review threads unresolved checks, results: 5
    • github api empty check runs list poll treat as failure not success, results: 5

    Sources:

    Checked on 2026-11-15. A person decides what this means for the item. The check changes no label and closes no issue.

  7. added
    status/ready
    and removed
    status/new
    on Nov 16, 2026
  8. devops-cli-service commented on Nov 16, 2026

    @devops-cli-service
    Contributor

    Status set to Ready at fccb781 (see proposed design in issue body).

  9. added
    status/in-progress
    status/in-review
    and removed
    status/ready
    status/in-progress
    on Nov 18, 2026
  10. removed
    status/in-review
    on Nov 18, 2026
  11. devops-cli-service commented on Nov 18, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-18 16:28 UTC

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

    effort/lowpriority/p2-mediumscope/githubsource/agenttype/bugvalue/high

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions