Repository navigation
Description
Analysis
The activation job's "Check workflow lock file" step (actions/setup/js/check_workflow_timestamp_api.cjs) recomputes the frontmatter hash by reading the workflow and every imported file through the GitHub Contents API (createGitHubFileReader, readerMode: "github-api"). A single transient HTTP 5xx on one imported file makes that import silently disappear from the hash, the recomputed hash then differs from the lock file's, and activation fails with stale_lock_file_failed. Nothing is wrong with the lock file.
Two pieces of code combine:
-
createGitHubFileReader().fetchFile(actions/setup/js/frontmatter_hash_pure.cjs) makes onerepos.getContentcall per file, with no retry. For any status other than 404 it throwsFailed to read file <path> from GitHub: <message>. -
processImportsTextBased(same file) wraps each import read in a bare catch that continues:try { const importContent = await fileReader(fullPath); ... } catch (err) { // Skip files that can't be read continue; }
readRuntimeImportBodyForHashandcollectImportedBodies(the body-hash path, used when the full stale check is enabled) have the same catch-and-continue. It treats "could not read" (a 500, a secondary rate limit, a timeout) the same as "not there". A genuinely absent file may reasonably be skipped, but an unreadable one changes the canonical hash input (imports,imported-frontmatters), so the check reportsHashes differand the run fails.
There is already a safety net that would have rescued this run. compareFrontmatterHashes wraps the API path in try { ... } catch { return compareFrontmatterHashesFromLocalFiles(); }, and the local workspace has all the files (the activation job checked them out). It is never reached, because the swallowed error never propagates.
Failing closed on a genuinely stale lock is right. The problem is only that a transient read error is reported as a stale lock: the log says Status: Hashes differ and a person is sent to recompile locks that are fine.
Still present on main (frontmatter_hash_pure.cjs, the catch at the same place) as of 2026-11-03.
Reproduction
Observed once, in a private repository, on gh-aw-actions/setup v0.93.5, engine: pi, a scheduled run of a workflow with six imports. Relevant log lines from the activation job (request id trimmed):
Checking for stale lock file using frontmatter hash:
...
GET /repos/<owner>/<repo>/contents/.github%2Fworkflows%2Fshared%2Freporting.md?ref=refs%2Fheads%2Fmain - 500 with id <id> in 6761ms
Frontmatter hash comparison:
Lock file hash: b771117744adb73dc736af85814de038f5d9a9ef69b90783185f96df0c756415
Recomputed hash: 6933bb4df62d2ba8a4430481a1466bf8a6e7a2955f67aa62d7fc75cd69640110
Status: Hashes differ
What I confirmed:
- The 500 on
shared/reporting.md(one of the workflow's six imports) is in the log, immediately before the mismatch. - The lock file was current: recompiling every workflow on the same commit with the same compiler version changes nothing for this workflow, the frontmatter and body sizes the check printed equal the real file's, and the same step passed on the two previous runs and on a sibling workflow the same morning.
- Re-running the failed job on the same commit, with no change, passed (attempt 2).
- It is rare for us: no other occurrence in roughly three weeks of run history.
What I inferred, not observed: which import was dropped in the failing pass. Nothing logs a skipped import. The verbose second pass ("Debug hash recomputation") later listed all six imports, i.e. its reads succeeded. The explanation above (the 500 was swallowed by the catch) fits the log and the code, but I could not see the first pass skip the file.
To reproduce deterministically: make the reader return a 5xx for one imported file (for example a github.rest.repos.getContent stub that rejects with { status: 500 } for one path) and run computeFrontmatterHash with readerMode: "github-api"; the hash differs from the one computed with all imports readable.
Implementation Plan
Smallest fix first; the second is optional hardening.
- Only skip an import that is really absent. In
processImportsTextBasedand the sibling import walkers infrontmatter_hash_pure.cjs, catch the error, continue only when it is a not-found (status === 404, orENOENTfor the local reader), and rethrow anything else. The existingcatchincompareFrontmatterHashesthen falls back tocompareFrontmatterHashesFromLocalFiles(), which has the files and matches, so activation passes. - Retry transient errors in the reader. In
createGitHubFileReader().fetchFile, retry 5xx and secondary-rate-limit responses a few times with a short backoff (honouringRetry-After) before throwing. Do not retry 4xx. - Say what happened. When the hash cannot be computed because a read failed (and the local fallback also fails), report
Could not read import <path> (HTTP 500)instead ofHashes differ, so the failure does not point at the lock file.
Acceptance Criteria
- With one imported file returning HTTP 500 on every API read, the stale-lock check does not report
Hashes differ: it either retries and succeeds or falls back to the local files and matches. - With one imported file returning 404 (genuinely absent), behavior is unchanged.
- A real mismatch (an edited import) still fails the check with
Hashes differ. - Unit tests in
frontmatter_hash_pure.test.cjs/check_workflow_timestamp_api.test.cjscover the 5xx, 404 and real-mismatch cases.
Workaround on our side: re-run the failed jobs (gh run rerun <id> --failed); nothing else needs to change.
Activity