fix(browse): bash.exe wrap for telemetry on Windows (v1.24 extension)#1306
Open
scarson wants to merge 1 commit intogarrytan:mainfrom
Open
fix(browse): bash.exe wrap for telemetry on Windows (v1.24 extension)#1306scarson wants to merge 1 commit intogarrytan:mainfrom
scarson wants to merge 1 commit intogarrytan:mainfrom
Conversation
reportAttemptTelemetry() in browse/src/security.ts calls spawn(bin, args) where bin is the gstack-telemetry-log bash script. On Windows this fails silently with ENOENT — CreateProcess can't dispatch on shebang lines. Adopts v1.24.0.0's Bun.which + GSTACK_*_BIN override pattern (from browse/src/claude-bin.ts:resolveClaudeCommand, introduced in garrytan#1252) for resolving bash.exe. resolveBashBinary() honors GSTACK_BASH_BIN absolute-path or PATH-resolvable override, falling back to Bun.which('bash') which finds Git Bash on the standard Windows install. buildTelemetrySpawnCommand() wraps the script invocation on win32 only; POSIX path is bit-identical. Returns null when bash can't be resolved on Windows so caller skips spawn — local attempts.jsonl audit trail keeps working without surfacing a Windows-only failure. 8 new unit tests cover resolveBashBinary (POSIX bash, absolute override, quote-stripping, BASH_BIN fallback, empty-PATH null) and buildTelemetrySpawnCommand (POSIX pass-through, win32 bash wrap, win32 null on unresolvable, arg-array immutability). POSIX path is bit-identical — Bun.which('bash') on Linux/macOS returns the same /bin/bash or /usr/bin/bash that the old hardcoded spawn relied on.
This was referenced May 3, 2026
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.
Summary
reportAttemptTelemetry()inbrowse/src/security.tscallsspawn(bin, args)wherebinis thegstack-telemetry-logbash script. On Windows this fails silently withENOENTon every attack-attempt telemetry event —CreateProcesscannot launch shebang-scripted files. The error is swallowed by the fire-and-forgetchild.on('error', ...)handler, so the failure is invisible — telemetry drops on the floor on every Windows install.This is a v1.24-aligned reshape of #1119 (closed in favor of this PR). v1.24.0.0 (#1252) introduced
Bun.which()+GSTACK_*_BINoverride pattern inbrowse/src/claude-bin.ts:resolveClaudeCommandfor theclaudebinary, fixing Windows PATHEXT resolution and thewhichPATH-fallback gap. This PR extends the same pattern to bash resolution —resolveBashBinary()honorsGSTACK_BASH_BIN(orBASH_BINback-compat) absolute-path or PATH-resolvable override, falling back toBun.which('bash')which finds Git Bash on the standard Windows install.buildTelemetrySpawnCommand()becomes a pure function over(platform, env, bin, args)— testable without spawning. POSIX returns{ cmd: bin, cmdArgs: args }unchanged (bit-identical to old code). Win32 returns{ cmd: <resolved-bash>, cmdArgs: [bin, ...args] }, ornullwhen bash isn't resolvable so caller skips spawn — the localattempts.jsonlaudit trail keeps working without surfacing a Windows-only failure.Empirical reproduction
Windows 11, Node v25, bun 1.3.11. Stand-in script for
gstack-telemetry-log:-4058isUV_ENOENT/ERROR_FILE_NOT_FOUND— libuv trying to execute the file as a PE image and getting rejected. With the fix applied (spawn(<resolved-bash>, [script, ...args])):Why this shipped unnoticed
.github/workflows/ran every job onubuntu-latestormacos-latest. v1.24.0.0 added the curated Windows lane (windows-free-tests.yml), which would run the new tests in this PR going forward. The 25 currently-excluded POSIX-bound tests are tracked as a separate v1.24 P4 follow-up.What changed from #1119
GSTACK_CLAUDE_BINshape (absolute path or PATH-resolvable, supportswsletc.).'bash'literal.nullinstead of always{cmd, args}— caller skips spawn cleanly when bash isn't available, no spuriousENOENTerror event.resolveClaudeCommandandresolveClaudeBinary).Test plan
bun test browse/test/security.test.tson win32 — 38 pass, 0 fail (8 new assertions:resolveBashBinaryPOSIX/absolute-override/quote-strip/BASH_BIN-fallback/null-on-empty-PATH;buildTelemetrySpawnCommandPOSIX pass-through/win32 bash wrap/win32 null/arg-array immutability)ENOENT→exit 0{ cmd: bin, cmdArgs: args }, no behavior change.What this PR doesn't do
spawn('claude', ...)sites in security-classifier.ts. Already routed through v1.24'sclaude-bin.ts:resolveClaudeCommand. ✅windows-free-tests.yml. ✅.ps1or.cmdwrapper alongsidegstack-telemetry-log. Larger change requiring infra to keep wrapper in sync; out of scope.🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmithwith what you need.