Make the sponsored guard test locale-independent - #1340
Conversation
|
This is a clean, well-reasoned fix. The root cause is correctly identified: The change is minimal, scoped to a single test file, and doesn't touch product code or forbidden paths. The comment added alongside the fix is a bit verbose for a one-line change but does explain the reasoning for future readers, which is fine. One minor note: it might be worth checking if other tests in the same suite or sibling suites spawn subprocesses the same way and could hit the same issue — but that's a nice-to-have, not a blocker for this PR. The verification steps (reproducing with |
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.