Repository navigation
🐛 fix(sink/git): pin LC_ALL=C so git stderr classification is locale-independent (REL-01) - #169
Merged
Merged
Conversation
…independent (REL-01)
There was a problem hiding this comment.
Pull request overview
This PR hardens the git CLI execution path by forcing a deterministic C locale for every git subprocess, ensuring stderr-based error classification remains reliable under non-English operator locales (REL-01), and makes the related tests non-leaky and locale-hermetic.
Changes:
- Always set
LC_ALL=CandLANG=Cfor git CLI subprocesses viaapplyCLIEnv, independent of auth/SSL env configuration. - Adjust tests to avoid logging
cmd.Env(preventing secret leakage) and add a regression test that proves locale pinning overrides ambient locale. - Add a small test helper to validate “last effective value” semantics for env key overrides.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| internal/sink/git/cli_env.go | Always pins LC_ALL/LANG for all git CLI subprocesses by default. |
| internal/sink/git/cli_env_test.go | Prevents env leakage in failures and adds a regression test ensuring locale pinning works under non-C ambient locale. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
+239
to
+240
| // lastValue returns the value of the final key=... entry in env, mirroring the | ||
| // last-wins semantics the OS applies to a process environment. |
Comment on lines
+113
to
+120
| // Always pin a deterministic locale so git stderr is English, then layer | ||
| // any auth/SSL extraEnv on top. Both are appended after os.Environ() so | ||
| // later entries win over inherited values. | ||
| env := append(os.Environ(), deterministicLocaleEnv...) | ||
| if cli != nil && len(cli.extraEnv) > 0 { | ||
| cmd.Env = append(os.Environ(), cli.extraEnv...) | ||
| env = append(env, cli.extraEnv...) | ||
| } | ||
| cmd.Env = env |
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
|
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.



REL-01 (P2) — git CLI error classification was locale-fragile
Surfaced by the 2026-08-02 /project-audit (reliability + tests lenses; live-reproduced). Git CLI error classifiers (
isCLIEmptyRemote,isNonFastForwardError,isTransientTransportError,isAuthFailure) match ENGLISH stderr substrings, butapplyCLIEnvonly setcmd.Envwhen auth/SSL extraEnv existed — so under a non-English operator locale (reachable via the documentedspec.git.engine: cli) git emitted localized stderr → transient pushes misclassified terminal (no retry), non-fast-forward undetected (no rebase recovery), first-export-to-empty-remote failed.Fix
applyCLIEnvnow ALWAYS pinsLC_ALL=C/LANG=C(appended afteros.Environ(), before auth/SSL extraEnv so those still win) on every git subprocess. This also makes the git test suite hermetic — the ~8 previously locale-flaky tests now pass regardless of ambientLANG.Review
Independent review caught a P1 (a pre-existing sibling test dumped
cmd.Envon failure → token-leak class, widened because the fix always sets cmd.Env); fixed and fresh-re-reviewed → APPROVE. Re-review confirmed no test failure path prints the environment, the locale pin covers all 5 git spawns, and the test is a genuine (non-tautological) driver. Gates green.