healer watchdog: watchdog_run_url ignores run status, so the bundle fetches the IN-FLIGHT run's job log — the publish rails' real fault text is unreachable by construction #2182

Open
opened 2026-11-09 18:15:35 +00:00 by matou-build-agent · 0 comments

Found by the healer while diagnosing watchdog incident 34d79489ef32 (reseed-publish always-red, attempt 9, 2026-11-09 18:03Z). The incident's own root cause is already filed (#2073 x #2074, compounded by #2057 / #2076) — this ticket is about the evidence bundle being structurally unable to carry the fault text for exactly the workflows that overrun their ceiling.

Symptom

heal.sh:879 hands collect_job_logs the output of watchdog_run_url:

handle_incident "$wf" "watchdog: $kind ($(error_line "$wf"))" "$(watchdog_run_url "$EVIDENCE/runs.json" "$wf")"

watchdog_detect (heal-lib.sh:206) filters to completed runs — select(.status == "success" or .status == "failure") — so the signature is keyed on the failures. watchdog_run_url (heal-lib.sh:239) applies no status filter at all:

[.workflow_runs[] | {wf: ..., n: .run_number, url: (.html_url // .url // "")}
  | select(.wf == $wf and (.url | length) > 0)]
| sort_by(-.n) | .[0].url // empty

It returns the highest run_number for the workflow regardless of status. So the bundle fetches the job log of a run that is still running, and gets the checkout prologue with no fault text in it.

Proof from this incident's bundle

runs.json for reseed-publish:

run_number status created updated
62294 running 17:46:47Z 17:53:25Z
62194 failure 17:24:56Z 17:43:46Z
62191 failure 16:52:50Z 17:08:46Z
62187 failure 15:59:50Z 16:18:46Z
62184 failure 15:28:44Z 15:48:46Z

watchdog_detect saw 62194/62191/62187/62184 — four of four failures — and emitted always-red. job-log.txt in the bundle is headed:

===== job 0 (attempt 1) - https://git.matou.nz/Matou/idss/actions/runs/62294/jobs/0/attempt/1/logs

i.e. run 62294, the in-flight one. Its content ends at git remote add origin with no error, because the run had not failed yet. Fetching 62194's log by hand (same URL shape, substituting the run number) gives the actual decisive text: the log stops mid-checkout at 17:30:08Z and emits nothing for the remaining 13.6 min of the job — the fetch --prune of all refs burning the timeout-minutes: 20 ceiling.

Why this is systematic, not a race

It is guaranteed for every workflow whose runs outlive their cron interval. reseed-publish fires every 10 min with cancel-in-progress: false, and each run takes 16-22 min. There is therefore always a queued-or-running run with a higher run_number than the newest completed one. For the two publish rails the watchdog can never reach a failing run's log — which is why #2057 sat for 17 days diagnosed from durations rather than logs. release-publish (cron every 10 min, 30-min ceiling) has the same shape.

Suggested fix

Give watchdog_run_url the same status predicate watchdog_detect uses, and prefer the newest failure — that is the run the signature was keyed on:

| select(.wf == $wf and (.url | length) > 0 and .status == "failure")

Reading .status into the projection and sorting failures first keeps the investigate-stale/streak cases intact. scripts/tests/ has no coverage for watchdog_run_url against a mixed running/failed runs.json — worth a case there, since the function is pure and offline-testable.

Secondary, same bundle

collect_job_logs probes legs 0..HEAL_JOB_LOG_MAX_LEGS-1 and appends every 2xx. For a single-job workflow this Forgejo serves the same job-0 log at every leg index, 200 each time, so job-log.txt ends up holding 20 byte-identical copies of the same 3.2 KB prologue — 99,940 of the bundle's ~100 KB, and 20 x 30 s of worst-case curl budget. Cheap guard: skip appending a leg whose body is byte-identical to one already written.

Not touched

.sandcastle/ is a protected dir and heal-lib.sh is one of the three files the heal charter forbids the healer from editing, so this is filed rather than repaired. No repair was attempted for the parent incident either.

Found by the healer while diagnosing watchdog incident `34d79489ef32` (`reseed-publish always-red`, attempt 9, 2026-11-09 18:03Z). The incident's own root cause is already filed (#2073 x #2074, compounded by #2057 / #2076) — this ticket is about the evidence bundle being structurally unable to carry the fault text for exactly the workflows that overrun their ceiling. ## Symptom `heal.sh:879` hands `collect_job_logs` the output of `watchdog_run_url`: handle_incident "$wf" "watchdog: $kind ($(error_line "$wf"))" "$(watchdog_run_url "$EVIDENCE/runs.json" "$wf")" `watchdog_detect` (heal-lib.sh:206) filters to completed runs — `select(.status == "success" or .status == "failure")` — so the signature is keyed on the failures. `watchdog_run_url` (heal-lib.sh:239) applies **no status filter at all**: [.workflow_runs[] | {wf: ..., n: .run_number, url: (.html_url // .url // "")} | select(.wf == $wf and (.url | length) > 0)] | sort_by(-.n) | .[0].url // empty It returns the highest `run_number` for the workflow regardless of status. So the bundle fetches the job log of a run that is still **running**, and gets the checkout prologue with no fault text in it. ## Proof from this incident's bundle `runs.json` for `reseed-publish`: | run_number | status | created | updated | |---|---|---|---| | 62294 | **running** | 17:46:47Z | 17:53:25Z | | 62194 | failure | 17:24:56Z | 17:43:46Z | | 62191 | failure | 16:52:50Z | 17:08:46Z | | 62187 | failure | 15:59:50Z | 16:18:46Z | | 62184 | failure | 15:28:44Z | 15:48:46Z | `watchdog_detect` saw 62194/62191/62187/62184 — four of four failures — and emitted `always-red`. `job-log.txt` in the bundle is headed: ===== job 0 (attempt 1) - https://git.matou.nz/Matou/idss/actions/runs/62294/jobs/0/attempt/1/logs i.e. run **62294**, the in-flight one. Its content ends at `git remote add origin` with no error, because the run had not failed yet. Fetching 62194's log by hand (same URL shape, substituting the run number) gives the actual decisive text: the log stops mid-checkout at 17:30:08Z and emits nothing for the remaining 13.6 min of the job — the `fetch --prune` of all refs burning the `timeout-minutes: 20` ceiling. ## Why this is systematic, not a race It is guaranteed for every workflow whose runs outlive their cron interval. `reseed-publish` fires every 10 min with `cancel-in-progress: false`, and each run takes 16-22 min. There is therefore **always** a queued-or-running run with a higher `run_number` than the newest completed one. For the two publish rails the watchdog can never reach a failing run's log — which is why #2057 sat for 17 days diagnosed from durations rather than logs. `release-publish` (cron every 10 min, 30-min ceiling) has the same shape. ## Suggested fix Give `watchdog_run_url` the same `status` predicate `watchdog_detect` uses, and prefer the newest **failure** — that is the run the signature was keyed on: | select(.wf == $wf and (.url | length) > 0 and .status == "failure") Reading `.status` into the projection and sorting failures first keeps the `investigate-stale`/`streak` cases intact. `scripts/tests/` has no coverage for `watchdog_run_url` against a mixed running/failed `runs.json` — worth a case there, since the function is pure and offline-testable. ## Secondary, same bundle `collect_job_logs` probes legs 0..`HEAL_JOB_LOG_MAX_LEGS-1` and appends every 2xx. For a **single-job** workflow this Forgejo serves the same job-0 log at every leg index, 200 each time, so `job-log.txt` ends up holding 20 byte-identical copies of the same 3.2 KB prologue — 99,940 of the bundle's ~100 KB, and 20 x 30 s of worst-case curl budget. Cheap guard: skip appending a leg whose body is byte-identical to one already written. ## Not touched `.sandcastle/` is a protected dir and `heal-lib.sh` is one of the three files the heal charter forbids the healer from editing, so this is filed rather than repaired. No repair was attempted for the parent incident either.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
Matou/idss#2182
No description provided.