fix(release): tolerate a release repeated across an offset page boundary - #71
Merged
Merged
Conversation
Distinguish the same release seen twice from two distinct releases sharing a tag, so a paginated re-read during draft creation no longer fails the publish.
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
Problem
A publish run failed with:
The tag named in the error belongs to a release from a year-old version that the run was not touching, and no duplicate release exists in the repository.
preparecreates the draft releases, thenwaitForStagedStatere-readsrepos/{repo}/releases?per_page=100throughgh api --paginateand hands the pages toindexReleases. That repository had just passed 100 releases, so the list spans two offset pages, and the tag in the error was the entry sitting on the page boundary.A draft becoming visible between the page 1 and page 2 requests shifts every later entry down one position, and the boundary entry is returned on both pages.
indexReleasessaw onetag_nametwice and failed the release.The comment immediately above that call already anticipates the underlying condition:
The duplicate is a symptom of exactly that lag.
waitForStagedStateexists to retry through it, butfail()insideindexReleasesruns first, so the retry never gets the chance.The failure is a race, so it is intermittent, and it is only reachable once a repository has more than one page of releases.
Change
Two releases sharing a tag remains fatal: GitHub allows any number of drafts on one tag, and publishing an arbitrary one of them is not a choice this action may make.
Seeing the same release twice is a different fact, and the release id separates the two cases. A repeat of an id already indexed is now skipped; a second id under a tag already indexed still fails.
The opposite shift, an entry skipped rather than repeated, needs no handling: a missing draft leaves its entry pending, and the existing retry re-reads the list.
The existing test encoded the bug
rejects duplicate drafts for the same package tagbuilt one draft object and passed it as two pages:That is the paging artifact, not two drafts. Two distinct drafts have distinct ids. The test has been given the fixture its name describes, and a second test covers the boundary repeat.
Verification
find .github -type f -name '*.test.mjs' -print0 | sort -z | xargs -0 node --test— 48 pass, 0 fail.Recovery on the affected repository confirmed the diagnosis: a plain re-run published all four packages and cleared the drafts, because the drafts already existed, no release was created, and the list therefore did not shift mid-read.
Follow-up not included
Offset pagination over a list this action concurrently appends to is unstable by construction; the id check makes the instability harmless rather than removing it. Worth revisiting separately, since consumers keep adding releases and the window only widens.