Repository navigation
fix(ghapp): find a queued job the status-filtered run list leaves out - #56
Conversation
…es out GitHub's runs?status=queued left a queued run out on 2026-11-21 and the job sat 25 minutes with no runner. These tests pin the fallback through the unfiltered run list and the healthz and log counts. They fail until the fallback exists.
…isses GitHub's runs?status=queued can leave a queued run out, and its job then never gets a runner. Every cycle now also reads the first page of the unfiltered runs list (once, no paging) and the jobs of each run that is not completed and was not listed; those jobs are marked Unlisted. On an idle repository the page is a 304 through the ETag cache. Proven by the new unlisted tests and the ghapp suite.
The gap on GitHub's side must stay visible once the fallback hides it: /healthz reports unlisted_jobs, the cycle line carries unlisted, and each such job is logged at warn with its repository and id. Docs list the fourth run read and its rate-limit cost. Proven by the controller unlisted test and the full suite.
The quality gate found two uncovered changed lines and five surviving mutants on lines this change touched. New tests cover a Railway list failure with an unlisted job, a failed jobs read on a listed run, and /healthz services after a reap; the summary test now starts the call counter above zero. Coverage baseline moves to 88.79% as the gate asks. Gate run locally: all five checks pass.
parsilver
left a comment
There was a problem hiding this comment.
Verdict: 1 Blocker. The fallback itself is right:
listed(ghapp.go:457) stops a listed run being read twice, andseenstops a job being returned twice.- The unfiltered page carries
total_count, so it is cached and comes back as 304. - Only
queuedjobs with matching labels are taken.filter=latesthandles re-runs, and completed runs are never read. - The 20-run limit is documented,
/healthzshows only counts, and the tests count requests.
Blocker
internal/ghapp/ghapp.go:483: if the extra unfiltered read fails (a 5xx, or a 403 rate limit), the whole scope read fails. Before this change the scope was still served from the filtered lists. A fallback must not make the common path worse. Log the failure (warn, repo and status only), count it, and keep the jobs already found. Add a test where the unfiltered read answers 500 and then 403 while a filtered job still gets its runner.
Suggestion
ghapp.go:503: a run created between the filtered reads and the unfiltered read, or one inrequested, is flaggedUnlistedwith no GitHub gap, which gives false warns. Re-check such a run's status, or don't flag runs younger than the cycle start.docs/deploy.md:149-154: runs inwaitingoraction_requiredalso have their jobs read every cycle. Add a worst case for a big org scope (active repos × 30 cycles/h) against the 5,000/h limit.controller.go:307(not new):seenis per scope, so an org scope and a repo scope on the same repo can count one job twice. Worth a follow-up.
Nit
internal/ghapp/unlisted_test.go:27: the fake saystotal_count:4but lists 5 runs.
The fallback read only adds jobs, so a 5xx or a 403 rate limit on it must not cost a scope the jobs its status-filtered lists found, which it did before the fallback existed. QueuedJobs now returns those jobs with an UnlistedReadError naming each repository and status; the controller logs it at warn, counts it on /healthz and the cycle line, and serves the jobs.
|
Fixed the Blocker from the review; ready for review again.
The suggestions are not in this round: no false-warn filter for runs created mid-cycle, no worst-case rate-limit sum in the deploy doc, and no follow-up yet for the per-scope |
parsilver
left a comment
There was a problem hiding this comment.
Round 2: no Blocker. The Blocker is fixed. A failed unfiltered read (5xx or a 403 at the rate limit) now comes back as UnlistedReadError. The scope keeps its filtered jobs and runners. Each failure is logged at warn with the repo and status only, and counted as unlisted_read_failures on /healthz and unlisted_read_failed on the cycle line. TestAFailedFallbackReadKeepsTheListedJobsAndIsCounted covers 500 and 403 together, and the next clean cycle clears the count. Docs and CHANGELOG match. The remaining round-1 suggestions (false Unlisted flags for runs created mid-cycle, and seen per scope) can wait.
Closes #55
What changed
GitHub's
runs?status=queuedlist can leave a queued run out. On 2026-11-21 it did so for 25 minutes, and the job never got a runner. Every cycle now also reads, for each repository, the first page of the unfiltered runs list (runs?per_page=20, read once, no paging). It then reads the jobs of each run that is notcompletedand was not already in a filtered list. Those jobs are served like any other and marked unlisted.ghapp:repoJobsremembers which runs the filtered lists returned. A newunlistedJobsdoes the fallback read, andjobsOfRunsis shared by both paths.Job.Unlistedmarks the jobs found only through the fallback.controller:/healthzreportsunlisted_jobs(the last cycle), thecyclelog line carriesunlisted=N, and each unlisted job is logged at warn with its repository and job id. These are counts only, since/healthzis public. No new state is kept between cycles.QueuedJobsreturns the jobs the filtered lists found together with anUnlistedReadErrornaming each repository and its status. The controller logs each one at warn (repository and status only), counts them on/healthzasunlisted_read_failuresand on the cycle line asunlisted_read_failed, and serves the jobs. A failed filtered list still fails the scope, as before.I went with the fallback rather than remembering webhook job ids. It keeps GitHub as the only source of truth and works when webhooks are off or a delivery is lost. The first draft of the plan read the unfiltered page only when the filtered lists found nothing. A fresh review pointed out that this breaks "within one cycle" when the same repository has another queued job, so the page is read every cycle.
Acceptance criteria
runs?status=queuedgets a runner within one cycle.TestAQueuedRunTheStatusFilterLeavesOutIsFoundThroughTheUnfilteredListuses a fake GitHub that leaves run 31 out of the filtered list and still lists a stale run.TestTheUnfilteredListIsReadEvenWhenAQueuedJobWasFoundcovers the case where another job was found in the same repository.TestAnUnlistedJobGetsARunnerAndIsCountedOnHealthzAndInTheLogshows the controller creates a runner for an unlisted job.completed) is not read at all: the test asserts no jobs request goes out for it. A run that is not completed but has no queued job (waiting) returns nothing.TestTheFallbackSkipsAVanishedRunAndKeepsTheListedJobsOnOtherErrorsanswers the unfiltered list, then an unlisted run's jobs, with 500 and with 403: the listed job is kept and the error names the repository and status.TestAFallbackWithNoAnswerNamesStatusZerodrops the connection.TestAnOrgNamesEveryFailedFallbackAndKeepsEveryListedJobfails two repositories of an org and reads the third;TestAFailedFilteredListAfterAFailedFallbackStillFailsTheScopekeeps a real read failure fatal.TestAFailedFallbackReadKeepsTheListedJobsAndIsCountedshows the controller creates the runner, does not fail the cycle, logsrepo=... status=...and counts the failures on/healthzand the cycle line, then clears the count on a clean cycle. All five failed on the code before this change./healthzunlisted_jobs, theunlisted=Nfield on the cycle line, and a warn line per job are all asserted in the controller tests, including when the Railway read fails in the same cycle.queuedlist returns no job, and its jobs are read exactly once (asserted by counting requests).Commands run
Quality gate run locally (
python .quality/gate.py --base origin/main), after the review fix:.quality/baseline.json)Controller.Cycle(15.0, base 15.2) andController.alertLate(17.0, base 17.0) are still over, no worse than base.QueuedJobsreached 10 with the change, so its repository loop moved intoreposJobs.The tests failed before the fix for the expected reasons: no job found, the fallback's errors not reported, and no
unlisted_jobson/healthz.Risks
304and does not count against the rate limit. A repository with recent activity pays one full call per cycle.waiting,requested,action_required) now has its jobs read every cycle while it stays on the first page. Onlyqueuedjobs with our labels are taken.Limits and what I could not verify
unlisted_jobswill show whether the fallback fires.