Skip to content

publish-tech-debt-archive.sh's _archive_get cannot tell 404 from a transient failure, so a failed _index.json read repeats a full re-archive until it clears

Id: TD-PPagop-26090602 · Status: open · Filed: 2026-09-06

scripts/publish-tech-debt-archive.sh’s _archive_get discards gh’s stderr and returns 1 for both ‘file does not exist’ (HTTP 404) and any transient failure (network, 5xx, auth blip), setting ARCHIVE_SHA/ARCHIVE_CONTENT to “” either way. For per-issue files this is harmless (the subsequent create PUT fails 422 against an existing file and is retried next run), but for the per-repo _index.json it has a cost asymmetry the header’s ‘nothing to diff against yet’ framing understates: a transient index-read failure makes every archived issue read as changed, so a repo with N issues re-fetches and re-PUTs all N files (~2N+1 API calls, N commits’ worth of no-op updates on the state repo), and the closing index PUT — attempted as a create with no sha against the existing file — fails too, so the identical full re-archive repeats on every subsequent daily run until the GET finally succeeds. Bounded and self-correcting, never wrong, but at 126+ issues per repo (the current agent-ops count) each affected run costs ~250 calls for nothing. Suggested fix: distinguish the two cases — e.g. capture gh’s stderr (or use gh api -i / inspect the exit path) and treat only a genuine 404 as ‘fresh archive’; on any other index-read failure, log and skip that repository’s write pass for the run (exit 1, retry next day), the same posture the script already takes when the label search fails. The Reviewer named this cost asymmetry in a PR #1184 comment but it was recorded nowhere durable.

Default: Make _archive_get report 404 distinctly from other failures and skip the repository’s write pass (with exit 1) on a non-404 index read failure, mirroring the existing label-search-failure posture.

Section titled “Default: Make _archive_get report 404 distinctly from other failures and skip the repository’s write pass (with exit 1) on a non-404 index read failure, mirroring the existing label-search-failure posture.”

Noticed while the Approver was judging https://github.com/Poetic-Poems/agent-ops/pull/1184.

Migrated to https://github.com/Pullwright/agent-ops/issues/2013.