Skip to content

Take a commit GitHub made despite reporting an error - #6

Merged
barnumbirr merged 1 commit into
masterfrom
fix/recover-landed-commit
Nov 4, 2026
Merged

barnumbirr merged 1 commit into
masterfrom
fix/recover-landed-commit

Conversation

@barnumbirr

Copy link
Copy Markdown
Contributor

createCommitOnBranch can answer Something went wrong while executing your query for a commit it has already made. pkghaus/packages run 41738316016 hit exactly that: act 0.2.96-1 landed as pkghaus/packages@2a8060a at 23:23:21Z, the error came back at 23:23:25Z, the step failed, and the land job never dispatched the release. master now carries a changelog the archive does not serve (pkghaus/packages#73 lists it).

The error comes inside a 2xx body, so curl's --retry never sees it. On any error the script now reads the branch tip (GET /repos/{owner}/{repo}/commits/heads/{branch}) and takes it as its own commit only if its parent is the checked-out HEAD, its tree is the staged tree (git write-tree) and GitHub reports it verified. Otherwise it retries, three attempts in all, pausing 5, 15 and 40 s so a branch that still resolves to its old tip can catch up. expectedHeadOid refuses every attempt after one has landed, so a retry cannot commit twice.

No new inputs or outputs. The success path is unchanged: one mutation, same sha output.

Blast radius: every caller of @v1 once v1 moves. On an error, a run now takes up to about a minute longer to fail than before, a genuine expectedHeadOid conflict included.

Tradeoff: the tree comparison fails closed on any difference GitHub introduces (file modes, say). That is the old behaviour, never a false success.

Verification

  • tests/run.sh: 26/26, as root and as uid 1001.
  • Pinned shellcheck, tests/lint-action.sh and pinned actionlint: clean.
  • Mutants: removing the parent, tree or signature check, the tip lookup, or the retry each fails the suite. The old script fails 5 of the new assertions.
  • The tree check against the incident: an index of pkghaus/packages@5553cf6 plus the two files of 2a8060a writes 7e24c8a, the tree GitHub built.

After merge: tag a release and move v1, which is what callers pin.

createCommitOnBranch can answer "Something went wrong while executing
your query" for a commit it has already made. pkghaus/packages run
41738316016 hit exactly that: act 0.2.96-1 landed as 2a8060a at
23:23:21Z, the error came back at 23:23:25Z, the step failed, and the
land job never dispatched the release, so master carried a changelog
the archive does not serve.

The error arrives in a 2xx body, so curl's --retry never saw it. On any
error the script now reads the branch tip over REST and takes it as its
own commit only if its parent is HEAD_OID, its tree is the staged tree
(git write-tree) and GitHub reports it verified. Otherwise it retries,
three attempts in all, pausing 5, 15 and 40 s so a branch that still
resolves to its old tip can catch up. expectedHeadOid refuses every
attempt after one has landed, so a retry cannot commit twice.

The tree comparison was checked against the incident: an index built
from 5553cf6 plus the two files of 2a8060a writes 7e24c8a, the tree
GitHub built. Any difference GitHub introduces, file modes included,
fails closed, which is the old behaviour.

Tests cover the landed commit, a retry after an error that did not
land, and an unsigned, wrong-tree or wrong-parent tip. Each of the
three tip conditions, the lookup and the retry was removed in turn and
the suite caught it.
@barnumbirr
barnumbirr merged commit e60ec6e into master Nov 4, 2026
1 check passed
@barnumbirr
barnumbirr deleted the fix/recover-landed-commit branch November 4, 2026 07:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant