Repository navigation
Take a commit GitHub made despite reporting an error - #6
Merged
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
createCommitOnBranchcan answerSomething went wrong while executing your queryfor 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
--retrynever 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-outHEAD, 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.expectedHeadOidrefuses 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
shaoutput.Blast radius: every caller of
@v1oncev1moves. On an error, a run now takes up to about a minute longer to fail than before, a genuineexpectedHeadOidconflict 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.tests/lint-action.shand pinned actionlint: clean.7e24c8a, the tree GitHub built.After merge: tag a release and move
v1, which is what callers pin.