Skip to content

fix(github): pr monitor polls again after one failed read #4838

Description

@dan-petty

Problem Description

devops pr monitor <n> --timeout 1800 stops at the first GitHub read that fails. One read of the pull request that times out after 30 s ends the whole watch with exit 1, although 1,700 s of the watch remain. The agent must start the monitor again by hand.

In src/devops_cli/github/pr_monitor.py, monitor_pr calls get_pr_monitoring_status in its loop with no handling of a failed read. fetch_pr_details raises GitHubOperationError ("Failed to query PR #: ...") when gh exits non-zero, and the error leaves the loop.

Reproduction Steps

  1. Open a pull request whose checks take more than one poll interval.
  2. Run devops pr monitor <n> --timeout 1800 while the GitHub API is slow (many sessions use one token).
  3. One read of the pull request times out.

Expected vs Actual Behavior

Expected: the monitor counts a failed read as a poll with no new data, says so, and polls again on the next interval until its own timeout. It stops early only when the reads fail for a bounded number of polls in a row, and then names the last error.

Actual: the monitor exits 1 at the first failed read.

Environment Diagnostics

devops-cli at main (2026-11-11), devcontainer, gh through the rate limiter of devops.

Logs, Traces, or Terminal Output

ℹ Monitoring PR #4794 for CI checks and review completion...
✗ Failed to query PR #4794: GitHub API command timed out after 30.0 seconds

Source: #4794

Activity

  1. added
    source/agent
    type/bug
    scope/github
    status/new
    value/medium
    effort/low
    on Nov 11, 2026
  2. dan-petty commented on Nov 11, 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: P2-Medium. The monitor stops after one failed read, forcing a manual restart, but a workaround exists.
    • Value: Medium. It removes a workflow interruption for every user who runs pr monitor under slow API conditions.
    • Effort: Low. The change adds a try-except with a bounded failure counter inside one existing loop.
    • Related: fix(github): pr monitor reports copilot as idle or completed when its timeline or reviews read fails #806, which asks for a different change. Both handle a failed GitHub read in pr_monitor.py, but #806 fixes what a failed Copilot read means while this candidate stops the loop from exiting on any failed read.
  3. added
    priority/p2-medium
    on Nov 11, 2026
  4. dan-petty commented on Nov 11, 2026

    @dan-petty
    OwnerAuthor

    One more case on 2026-11-11, PR #4820: devops pr monitor 4820 --timeout 1800 printed ✗ Failed to query PR #4820: GitHub API command timed out after 30.0 seconds after one poll at 0s and exited after 5 minutes. The checks of the pull request were still queued, so a second poll would have read the same state.

  5. dan-petty commented on Nov 11, 2026

    @dan-petty
    OwnerAuthor

    One more occurrence (2026-11-11, about 21:10 UTC): uv run devops pr monitor 4801 --timeout 1800 stopped after one read with this line, while the checks of the re-run were still in progress:

    PR #4801 check verification failed closed: GitHub check-runs API error: GitHub gave no readable answer to GET /repos/dan-petty/devops-cli/commits/539ea451.../check-runs?per_page=100 (page 1): ConnectTimeout

    The rule A GET that loses its connection is sent again of openspec/specs/github-session-retry/spec.md names RemoteProtocolError, ReadError and WriteError, but not ConnectTimeout. A GET that never connected sent nothing, so a resend is safe. The same output also gives the hint gh run view --log-failed <run_id>, which is a bare gh command (AGENTS.md rule 7).

  6. dan-petty commented on Nov 11, 2026

    @dan-petty
    OwnerAuthor

    One more occurrence on 2026-11-11: devops pr monitor 4826 --timeout 1800 stopped with exit 1 after 18 min 16 s with "Failed to query PR #4826: GitHub API command timed out after 30.0 seconds", when 31 of 32 checks were done. In the same minutes, devops gh rate-limit and one devops gh api -X POST also timed out after 30 s, but the POST had effect on GitHub.

  7. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    One more case on 2026-11-12: devops pr monitor <pr> --timeout 1800 stopped after 2 minutes. It printed "Checks: 13/23 passed", then "Failed to query PR: GitHub API command timed out after 30.0 seconds", and exited. The checks were still running.

  8. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    Another case on 2026-11-12: devops pr monitor 4916 --timeout 1800 stopped after 6 minutes at one failed read, ✗ Failed to query PR #4916: error connecting to api.github.com. I started the monitor again by hand.

  9. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    Seen again on 2026-11-12: devops pr monitor 4931 --timeout 1800 stopped after 82 s with "Failed to query PR #4931: GitHub API command timed out after 30.0 seconds" (exit 1). The checks were still running. The host load average was about 40 at that time.

  10. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    New evidence, 2026-11-12: devops pr monitor 5070 --timeout 1800 stopped after 4 min 33 s at one failed read of the pull request: ✗ Failed to query PR #5070: gh: HTTP 503. At that time 11 of 27 checks were done, and 1,527 s of the watch remained. A 503 is a server error that GitHub can answer again, so the monitor must poll again on the next interval, as this issue asks.

  11. 1 remaining item

  12. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    It occurred again on 2026-11-12. devops pr monitor 5106 --timeout 1800 stopped after 5 m 39 s with one failed read and exit code 0, while 6 of 30 checks were still not done:

    ℹ [270s] Checks: 24/30 passed (24/30 done)
    ✗ Failed to query PR #5106: gh: HTTP 503
    Elapsed: 5m 39s
    

    I started the monitor again by hand.

  13. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    One more case, on 2026-11-12 at about 15:20Z: devops pr monitor 5113 --timeout 1800 stopped after 418 s with ✗ Failed to query PR #5113: gh: HTTP 503, while 4 of 21 checks still ran. A new start of the same command stopped after 2.5 s with the same line. The REST read of the check runs of the same commit (devops gh api repos/{owner}/{repo}/commits/<sha>/check-runs) worked at the same time. So an HTTP 503 of GitHub is a second error that the monitor must count as a poll with no new data.

  14. dan-petty commented on Nov 12, 2026

    @dan-petty
    OwnerAuthor

    Seen again on 2026-11-12 with PR #5110: devops pr monitor 5110 --timeout 1800 stopped at 146 s with Failed to query PR #5110: gh: HTTP 503, exit 1. devops pr ready 5110 failed the same way one time and passed on a second run 20 s later. So a single 503 also stops pr ready, not only the monitor loop.

  15. added
    status/in-progress
    and removed
    status/new
    on Nov 14, 2026
  16. added
    status/in-review
    and removed
    status/in-progress
    on Nov 14, 2026
  17. removed
    status/in-review
    on Nov 14, 2026
  18. added a commit that references this issue on Nov 14, 2026
  19. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor
  20. devops-cli-service commented on Nov 14, 2026

    @devops-cli-service
    Contributor

    Live since 2026-11-14 15:02 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/medium

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions