You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix: Windows grep outage and test-run telemetry pollution
Two production defects found in Azure telemetry over 2026-07-22 → 2026-08-05.
**Windows `grep` broken for 99 machines**
`core_failure` showed 328 events across 99 distinct Windows machines (of 617
total) carrying `? is not recognized as an internal or external command,
operable program or batch file.` and its German, French, Spanish and Portuguese
translations. Present on released 0.9.2, 0.9.3 and 0.9.4.
Root cause: ripgrep's Windows release is a zip, and `RipgrepBinary` extracted it
via `powershell.exe -Command Expand-Archive`, falling back to the literal string
`"powershell.exe"` when neither `powershell.exe` nor `pwsh.exe` resolved.
`cross-spawn`'s `parseNonShell()` sets `needsShell = true` when `resolveCommand()`
returns undefined and re-spawns through `cmd.exe /d /s /c`, so cmd.exe produced
that message. `throw new Error(result.stderr.trim())` made it the error verbatim,
and since `RipgrepBinary.filepath` is `Effect.cached`, one failed extraction broke
grep for the whole session.
Upstream carries the same fragility: anomalyco/opencode#24291 is open, reporting
`Expand-Archive` unusable when spawned from the Bun-compiled binary, affecting
`grep`, `glob` and `skill`. Their #23457 fix only corrected how paths were passed
to PowerShell (the `$args` → inlined-and-escaped form we already carry); it did
not remove the dependency on PowerShell being resolvable.
Extract the zip in-process with `@zip.js/zip.js`, converging on the approach the
`packages/opencode/src/file/ripgrep.ts` shim already uses in production.
`unzipExecutable` is exported so archive handling is tested directly, and decodes
with `checkSignature: true` — zip.js defaults it off, and a CRC-corrupt download
would otherwise be written to the cache and trusted by every later session.
Install the binary atomically (stage to `rg.exe.tmp`, then rename). `filepath`
trusts the cached binary on existence alone, so an interrupted write previously
left a truncated `rg.exe` that every later session reused — the same permanent
breakage `checkSignature` guards against, which CRC cannot catch because it is
verified before the write. The tar path installs the same way.
Attribute resolution failures. Child stderr was reported verbatim, so a
shell-level failure was indistinguishable from a tool bug; and because a resolve
failure is memoized, it is re-reported on every later grep in the session. The tar
branch now names ripgrep, and any typed filesystem or HTTP failure is wrapped as
`ripgrep binary resolve failed: …`.
Note the blast radius is wider than the `grep` tool: `@opencode-ai/core/ripgrep`
also backs the HTTP-API file handlers and `cli/cmd/debug/ripgrep.ts`.
**Test runs shipped telemetry to the production resource**
1,020 of 3,135 machine ids in the same window emitted `provider_id="test"` /
`cli_version="local"` — test processes that regenerate their machine id every
run, inflating install and active-machine counts by roughly a third. `doInit()`
gated only on `ALTIMATE_TELEMETRY_DISABLED`.
Refuse the baked-in connection string when `NODE_ENV=test`, `BUN_TEST`, `VITEST`
or `JEST_WORKER_ID` is set. Keyed on test runners, deliberately not on CI:
`altimate-code-actions` wraps this CLI, so every run of that shipped product sets
`CI`/`GITHUB_ACTIONS`, and gating on those would blind a real product surface.
`bun test` sets `NODE_ENV=test`, which covers CI and developer machines alike.
An explicit `APPLICATIONINSIGHTS_CONNECTION_STRING` is always honoured, so suites
with their own sink are unaffected; `ALTIMATE_TELEMETRY_FORCE=true` overrides the
default-sink refusal, and the existing opt-outs still win over both.
Test plan: 8 ripgrep tests — including a layer-level test that drives `filepath`
through the Windows zip path with a spawner that fails if invoked, asserting the
staged-then-renamed install, and a CRC case that fails without `checkSignature` —
plus 15 telemetry-gate tests covering CI-alone-still-reports and one that relies
on the real runner's `NODE_ENV`. `turbo typecheck` green, marker guard green,
`packages/core` and `packages/opencode` suites show no failures beyond the
pre-existing set on `main`.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
0 commit comments