Repository navigation
test: the release scripts' stand-in gh is safe when two calls run at once (flaky JSONDecodeError) - #2130
Merged
Conversation
…aves its state whole release_files.sh check runs two gh calls at once (cmp <(sums) <(uploaded)). Every stand-in call appends to the state's call list and rewrites the file, so one call could read it while the other had it truncated: JSONDecodeError at line 1, and test_tag_pushed_by_hand_gets_its_release_and_sums failing now and then (main at 364d199, #2127). The stand-in now holds a lock for its whole run and writes the state through a temporary file. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.
tests/test_release_scripts.pyfails now and then on Linux, as it did on main at 364d199 and on #2127. The failing test istest_tag_pushed_by_hand_gets_its_release_and_sums; the stand-inghhitsjson.decoder.JSONDecodeError: Expecting value: line 1 column 1when it reads its state file.The cause:
scripts/release_files.sh checkruns twoghcalls at the same time (cmp -s <(sums "$id") <(uploaded "$id")). Every stand-in call appends itself tocallsand rewrites the state file withopen(STATE, "w"). So one call can read the file while the other has just truncated it.The stand-in now:
fcntllock for the whole call, so calls take turns and no entry incallsis lost;os.replace.The test is the only thing changed; the release scripts stay as they are. It needs
jqand only runs on Linux, so this was not run locally; CI checks it.🤖 Generated with Claude Code