Repository navigation
fix(enrich-outage): skip runs with no failed attempt - #1248
Conversation
tend-agent
left a comment
There was a problem hiding this comment.
run_jobs fetches .../jobs?filter=all through github_cli.json_call, which sets no per_page, so GitHub returns only the first 30 rows. The new guard reads that partial list as the whole truth: when a cited run has more than 30 job rows across its attempts and none of the first 30 carries conclusion == "failure", failure_details returns None, render_batch skips the run, and nothing is posted and no marker is written — so the diagnosis never reaches the tracker and no later nightly recovers it. Before this change the same run fell through to log_details(repo, run_id, failed_attempt(jobs)) with attempt=None, where gh run view --log-failed resolves the failing job itself and posted a real log tail. A ci-fix tracker cites the watched workflow's run, and adopter CI matrices past 30 legs are ordinary; filter=all stacking attempts reaches the page boundary sooner still.
Gating on the run's own conclusion instead of the jobs' would not fix it — that field reads success after a rerun-to-green, which is the attempt run_jobs' docstring says filter=all exists to keep. Widening the page is the fix, so I'll push &per_page=100 on the jobs read and a test asserting it.
The green-run guard reads a jobs list with no failed row as a run that never failed. `json_call` sets no `per_page`, so GitHub capped the read at 30 rows and a wide matrix — or a narrow one whose attempts stack past the cap — was dropped with no section and no marker.
|
@tend-agent
|
…ne page GitHub caps the jobs endpoint at 100 rows per page while a matrix can create 256 jobs before rerun attempts stack on top. The green-run guard reads a nonempty response with no failed row as a run that never failed, so a failed job on a later page skipped the run with no section and no marker. Read every page via `gh api --paginate`.
|
Right — 100 is still a cap, and a matrix run can exceed it before rerun attempts stack on top. Fixed in 2495efd: New test |
tend-agent
left a comment
There was a problem hiding this comment.
failure_details's new guard reads a run as green when no job carries conclusion == "failure", but a failed run isn't the only kind the tracker cites. tend-ci-fix fires on cancelled runs too — its job if: gates on contains(fromJSON('["failure", "cancelled"]'), github.event.workflow_run.conclusion) — and a cancelled run's jobs conclude cancelled, never failure; the same holds for timed_out, which red_default_branch_runs.py already counts among RED_CONCLUSIONS. So a run whose jobs are all cancelled or timed_out now returns None, render_batch skips it, and no section and no marker are written — and where it's the only run an issue cites, main posts nothing at all. Nothing records that the run was seen, so no later nightly recovers the diagnosis. That is the same silent drop the pagination fix in this PR exists to prevent, reached through the conclusion value instead of the page boundary.
Confirmed against the test harness: serving the cited run a single cancelled job renders an empty body on this head, and renders the log tail plus its marker once the guard is widened.
The fix follows in this session — the guard matches a module-level UNSUCCESSFUL set of failure, cancelled, timed_out. An absent conclusion (None) stays out of that set deliberately: an attempt still in flight should be left unmarked so a later nightly enriches it rather than spending a durable marker on a run that hasn't finished. That behavior is new in this PR and gets its own regression test alongside the cancelled-run one. failed_attempt needs no change — it wants the attempt whose log holds the error, and a cancelled attempt has none, so an all-cancelled run falls back to --log-failed on the latest attempt as before.
The green-run guard matched `conclusion == "failure"` alone, so a run whose jobs are all cancelled or timed out read as green and was dropped with no section and no marker. ci-fix fires on cancelled runs as well as failed ones, so its tracker cites exactly those. Match an UNSUCCESSFUL set instead; a conclusion still absent stays out of it, leaving an unfinished run unmarked for a later nightly.
tend-agent
left a comment
There was a problem hiding this comment.
Widening the guard to cancelled and timed_out keeps those runs out of the silent-drop path, but the detail path they now reach has nothing to give them: annotation_details still filters conclusion == "failure", and gh run view --log-failed selects failed steps, which a cancelled job has none of. So a cancelled run renders No failure details could be extracted. and takes a durable <!-- enriched-run: --> marker — the same sentence and the same permanence this PR exists to stop a green baseline from getting, reached through the branch the last commit added.
Checked against real runs rather than the fixture, whose fake gh serves a log tail for any --log-failed call: on run 34772565174 (one cancelled job) and run 34067831347 (success/skipped/cancelled), --log-failed returns empty with exit 0, while the cancelled job's annotations endpoint carries a failure-level Canceling since a higher priority waiting request for … exists. That annotation is the run's whole diagnosis, and the marker makes dropping it permanent.
Pushed as a follow-up commit: an annotated_jobs helper returns the failed jobs wherever any failed, and otherwise the rest of UNSUCCESSFUL. Keeping failures first is the part that matters — a fail-fast matrix cancels the failed job's siblings, so annotating every unsuccessful row unconditionally would bury the one real error under N copies of The operation was canceled. and spend MAX_RUN_BYTES on them. failed_attempt stays on failure alone: it picks the attempt whose log holds the error, and widening it would let a later cancelled attempt outrank an earlier failed one and blank the log tail.
Two tests: the cancelled-run case now serves an empty --log-failed the way the real CLI does and asserts the annotation is what carries the section (it fails on b6ff1ed, rendering the No failure details sentence), and a fail-fast matrix asserts only the failed leg is reported.
A cancelled or timed-out run has no job with `conclusion: failure`, so `annotation_details` rendered nothing for it and `gh run view --log-failed` — which selects failed steps — returned nothing either. The run took a durable marker alongside "No failure details could be extracted.", while its annotation naming the cancelling request went unread. `annotated_jobs` returns the failed jobs wherever any failed, and the rest of `UNSUCCESSFUL` otherwise. Failures stay first so a fail-fast matrix reports its one real error rather than every sibling's cancellation.
tend-agent
left a comment
There was a problem hiding this comment.
annotated_jobs' fallback returns every unsuccessful job, and a cancellation annotates all of them identically, so a run that only cancelled renders one copy of the same section per job. On run 34065429908 all four Analyze (…) jobs carry The run was canceled by @github-advanced-security[bot].; fed those rows, this head renders four identical #### … blocks, and a wider matrix repeats the line until MAX_RUN_BYTES cuts it off — half of MAX_BATCH_BYTES spent on the repetition, pushing the issue's other cited runs into a later batch. That is the noise this commit's own rationale gives for keeping failures first, reached through the fallback branch instead of the fail-fast one, and it is new here: before this PR a job that didn't fail was never annotated at all.
Fix follows in this session — the fallback keeps one job per conclusion rather than every job. Both conclusions stay, because a timeout cancels its siblings, so the job naming the exceeded limit would otherwise be hidden behind a cancelled row. The failed-job path is untouched, so a matrix of genuinely failed legs still reports each leg.
Two tests: a four-job cancelled run asserts its annotation renders once, and a timed_out job among cancelled siblings asserts it survives while the repeated cancelled rows do not. Both fail on 9fc87a0.
A run-level cancellation annotates every job with the same message, so the fallback for runs with no failed job rendered one identical section per job. A wide matrix repeated that line until `MAX_RUN_BYTES` cut it off, spending half the batch budget on the repetition and pushing the issue's other cited runs into a later batch. The fallback now keeps one job per conclusion. Both conclusions stay because a timeout cancels its siblings, so the job naming the exceeded limit would otherwise be hidden behind a cancelled row. The failed-job path is untouched.
tend-agent
left a comment
There was a problem hiding this comment.
annotated_jobs' fallback keeps one job per conclusion, and the dict comprehension keeps the last of them — which on a real cancelled run is routinely the job that was cancelled before it started and carries no annotation at all. The annotated sibling is dropped, annotation_details returns nothing, --log-failed has nothing to give a cancelled job, and the run renders No failure details could be extracted. and takes its durable <!-- enriched-run: --> marker. That is the outcome this PR exists to prevent, now reachable on a run whose diagnosis was sitting right there.
Checked against a real run rather than the fixture, whose fake gh serves the same annotations for every job: max-sixty/leaf run 34926635256 has two cancelled jobs — lint (started, annotated Canceling since a higher priority waiting request for ci-pull_request-720 exists) and test (steps: 0, never started, no failure annotations). Fed those rows, this head renders the No failure details sentence plus the marker; 9fc87a0 rendered lint's annotation.
Fix follows in this session — the dedup moves from the job selection to the rendered message. The fallback goes back to every unsuccessful job, and annotation_details skips one whose message block it has already rendered. A run-level cancellation still reports once, a job with no annotation now falls through to the sibling that has one instead of standing in for it, and deduping on content cannot drop a distinct diagnosis: the timed-out job among cancelled siblings survives because its message names the exceeded limit, not because its conclusion was grouped separately. annotated_jobs folds back into annotation_details, which is where the seen set has to live, and the failed-job path is excluded from the dedup so a matrix of legs failing the same assertion still reports each leg.
The fake gh now serves per-job annotations, which the old fixture could not express. test_a_timed_out_job_survives_its_cancelled_siblings gave every job identical annotations, so it could not distinguish the selection it was pinning; it now gives the cancelled siblings The operation was canceled. and the timed-out job the limit message. A new test serves a never-started cancelled sibling no annotations and asserts the run is still enriched from its sibling — it fails on 4f6b891 with exactly the No failure details body above.
…lusion Keeping one job per conclusion picked the last row of each, which on a real cancelled run is routinely a job cancelled before it started: it carries no annotation at all, so the annotated sibling was dropped and the run rendered "No failure details could be extracted." with its durable marker — the outcome this branch exists to prevent, on a run whose diagnosis was available. The fallback goes back to every unsuccessful job and the repeat is dropped on the rendered message instead. A run-level cancellation still reports once, a job with no annotation falls through to the sibling that has one, and a distinct message — the timeout naming the exceeded limit — can never be the one dropped. The failed-job path stays out of the dedup, so a matrix of legs failing the same assertion still reports each leg. The fake `gh` now serves per-job annotations, which the timed-out test needed to pin its selection at all.
|
CI on |
Ships #1277. bubblewrap's CVE-2026-87766 fix reached the Ubuntu archive this afternoon, and every consumer's sessions have died at sandbox launch since — consumers pin an immutable tag, so the fix reaches them only through a release. Also carried: the `tend-notifications` conflict-gate and subject-owner fixes (#1276, #1264), the outage-enrichment skip (#1248), the sandbox Git identity seed (#1252), and the split of tend's own maintainer calls out of the shipped skills (#1265, #1267, #1268, #1269, #1272). `review` will fail on this PR for the same reason the release exists: the reviewer runs `max-sixty/tend/[email protected]`, which is the broken pin. > _This was written by Claude Code on behalf of max-sixty_ Co-authored-by: Claude Opus 5 (1M context) <[email protected]>
Problem
enrich_tend_outage_issues.pycollects run IDs by regex over the issue body and comments, and nothing downstream asks whether those runs failed. Aci-fixdiagnosis routinely cites green runs as its comparison baseline, so each of those got its own### Run …section reading "No failure details could be extracted." — a sentence that means the logs aged out, not that the run passed. The tracker then reads as if several undiagnosable failures had occurred, and the one real log tail is buried among them.Solution
failure_detailsnow returnsNonewhen the jobs read came back with rows and none of them is unsuccessful.render_batchskips those runs entirely — no section and no<!-- enriched-run: -->marker, so a later rerun of that run to red is still enrichable — andmainposts nothing when a batch renders empty."Unsuccessful" is
failure,cancelled, ortimed_out:tend-ci-fixfires on cancelled runs as well as failed ones, so its tracker cites runs whose jobs never carryconclusion: failure, and reading those as green would drop the diagnosis. A conclusion still absent is deliberately excluded — an attempt that has not finished is left unmarked for a later nightly rather than spending a durable marker on it.Those runs then need a diagnosis to render.
gh run view --log-failedselects failed steps, which a cancelled job has none of, so the annotation naming the cancelling request or the exceeded limit is all there is.annotation_detailsreports the failed jobs wherever any failed — a fail-fast matrix reports its one real error rather than every sibling'sThe operation was canceled.— and otherwise every unsuccessful job, rendering each distinct message once. Cancellation and timeout are run-level events that annotate every job identically, and repeating that line would fill the run's byte budget; deduping the rendered message rather than picking one job per conclusion is what keeps a job cancelled before it started — which carries no annotation at all — from standing in for the sibling that holds the diagnosis.An unreadable jobs response yields no rows at all, which is not evidence the run was green; the
jobs andguard keeps those on the existing path, still falling back to the latest attempt's log.Because the green guard reads a list with no unsuccessful row as a run that never failed, the jobs read has to return every row.
json_callset noper_page, so GitHub capped it at 30, and evenper_page=100caps below the 256 jobs a matrix can create before rerun attempts stack on top — enough for a failed row to land past the cap and the run to be dropped with no section and no marker.run_jobsnow reads the endpoint throughgh api --paginateand concatenates every page'sjobs.Testing
Eleven tests in
generator/tests/test_enrich_tend_outage_issues.py: a green baseline cited alongside a real failure is omitted while the failure is still enriched, an issue citing only green runs posts nothing and never fetches a log, an unreadable jobs response still renders and marks the run, a run whose attempts are still going is left unmarked, the jobs read goes through--paginate, a failed job on the second page is enriched, a cancelled run is enriched from its annotation, a cancelled matrix renders that annotation once, a never-started cancelled job's sibling still carries the run, atimed_outjob survives its cancelled siblings, and a fail-fast matrix reports only the leg that failed. All but the unreadable-response one fail before their respective change. The fakeghnow serves per-run jobs responses — optionally as the multi-document page stream--paginateemits — and per-job annotations, so one batch can mix green and failed runs and one run can mix annotated and never-started jobs.Closes #1246 — automated triage