fix: clear the Changed bit when resetting api test flags, and shuffle in CI - #114
Merged
Conversation
go test -shuffle failed on 4 of 5 seeds. resetAPICmdFlags emptied --query and --header but left pflag's Changed bit set, and repeatableStringFlag rejects a flag that was set while holding no values — so a reset flag read as "the user passed an empty value" and leaked "requires a non-empty value" into whichever api test ran next. The change in #111 introduced the sensitivity; the reset predates it. resetCmdFlags already handled both traps, so resetAPICmdFlags delegates to it rather than keeping a second implementation that drifted. Delegating also covers the persistent flags cobra merges in, which fixes a second leak: one api test passed --dry-run through rootCmd and nothing cleared it. CI runs a shuffled pass. -shuffle=on rather than a fixed seed: the permutation is derived from the test list, so any added or renamed test rerolls a fixed seed anyway, and a failure prints its seed to replay with. Co-Authored-By: Claude Opus 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.
go test -shufflefailed on 4 of 5 seeds.resetAPICmdFlagsemptied--query/--headerwithpflag.SliceValue.Replacebut never cleared pflag's
Changedbit.repeatableStringFlagrejects a flagthat was set while holding no values, so a reset flag read as "the user passed
an empty value" and leaked
into whichever
apitest happened to run next. #111 introduced thesensitivity; the reset predates it.
The fix
resetCmdFlagsalready handled both traps —Setappending on aStringArray,and the
Changedbit — soresetAPICmdFlagsdelegates to it instead ofcarrying a second implementation that drifted. Net −25/+11.
Delegating also covers the persistent flags cobra merges into a subcommand's
flag set, which fixes a second leak: one api test passes
--dry-runthroughrootCmdand nothing cleared it afterward.Gated, so it stays fixed
CI now runs a shuffled pass.
-shuffle=onrather than a fixed seed: thepermutation is derived from the test list, so adding or renaming any test
rerolls a fixed seed anyway, and a failure prints its seed to replay with.
Verified the gate detects the bug rather than decorating the workflow — with
the old reset restored,
-shuffle=onfails 5 of 6 runs; with the fix, 0 of 6.Seeds 1–50 and
-raceare clean. The diagnosis is complete rather than onesymptom of several: with only the old
api_test.gorestored, 6 of 7 seeds failand every failure carries the same
--querymessage.🤖 Generated with Claude Code