Make the sponsored guard test locale-independent - #1340
Open
KazenDev wants to merge 1 commit into
Open
Conversation
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.
The sponsored rooted filesystem test asserts on the message
mkdirprints, and coreutils translates that message. So it passes on the English CI runners and fails on any machine with a non-English locale. Here the suite is 615 pass / 1 fail, and this is the one failure:Repro:
bun run --cwd sdk testfails withLANG=es_CO.UTF-8and passes withLC_ALL=C. Nothing about the guard is broken — the write is still refused, andescaped.tsis still never created. Only the wording the test listens for is wrong.Root cause
The test's
directBroker()spawns the helper withenv: request.env, andgetSystemProcessEnv()(sdk/src/env.ts) returnsprocess.env, so the test machine's locale reachesmkdir.mkdirwrites its localized message to stderr, andrunHelperthrows that stderr verbatim:Fix
Pin the locale on the helper subprocess, in the test's own broker:
The assertion itself is left exactly as written.
LC_ALL=Calone is enough — it takes precedence overLANGandLANGUAGE.Why pin the locale instead of loosening the assertion
Loosening the pattern to
/mkdir:.*late|helper exited with code 74/also makes it pass anywhere, but it costs precision: it stops checking the reason, andlatethen matches the prefix of a longer name such aslate-ishorlatex. Pinning the locale keeps the original assertion, reason text included, and leaves nothing cryptic behind.It is also the established fix for this exact problem:
LC_ALL=Cin the test suite.LC_ALLdirectly."Who this helps
Anyone running the SDK suite outside an English locale. This is currently the only red test in the suite, and it is red for a reason that has nothing to do with the code under test — so a contributor on a Spanish, German or Chinese machine either sets the locale by hand or learns to ignore a real-looking failure. After this, local matches CI.
Verification
Public CI builds the SDK and smoke-tests the binary, but it does not run this suite, so this was reproduced locally:
LANG=es_CO.UTF-8 bun run --cwd sdk test— 616 pass, 0 failLC_ALLpin brings the original failure back with the Spanish message, so the pin is what fixes itbun run --cwd sdk typecheck— cleanprettier --checkon the file — cleanFollow-up, not in this PR
runHelperalready has a stable, locale-proof message of its own (Sponsored filesystem helper exited with code N), but it prefers the localized stderr whenever there is any, so the structured signal only surfaces whenmkdirsays nothing. Preferring the structured message there — or forcing a locale for sponsored helpers generally — would fix the class of problem rather than this instance. The second one changes the environment every sponsored command runs in, not just this test, so it is raised here rather than changed unilaterally.