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
{{ message }}
Repository navigation
fix(opencode): handle literal Windows archive paths - #43038
Pass Windows archive and destination paths through child-process environment variables instead of interpolating them into a PowerShell command.
It also switches Expand-Archive from -Path to -LiteralPath. This preserves apostrophes in valid paths and prevents characters such as [ and ] from being interpreted as wildcards.
A Windows regression test covers archive and destination paths containing both kinds of characters.
How did you verify your code works?
Ran bun test test/util
120 tests passed with 0 failures
Verified extraction using paths such as archive's [copy].zip and destination's [copy]
AI code review — automated review for reference; please use your judgment.
packages/opencode/src/util/archive.ts:6 — solid fix: routing the paths through $env: removes both the single-quote injection hole (a path like x'; Remove-Item ...) and the wildcard/globbing misparse that motivated this ([copy] under non-literal -Path). Consider also asserting in Process.run's contract (or a comment here) that envmerges with process.env — if it ever switches to replace-semantics, PowerShell on Windows can fail to start without SystemRoot, and this call site would be the reason.
packages/opencode/src/util/archive.ts:9 — with paths no longer embedded in the command string, failures now log a command that contains only $env:... placeholders, so a broken extract shows "Expand-Archive failed" with no clue which file was involved — make sure the thrown error from Process.run still carries stderr (and ideally the resolved OPENCODE_ARCHIVE_PATH value) for debuggability.
packages/opencode/test/util/archive.test.ts:7 — the guard if (process.platform !== "win32") return makes the test silently pass on Linux/macOS CI; prefer test.skipIf(process.platform !== "win32") so the skip is visible in reports and someone notices when zero Windows runs happened in a PR touching Windows-only behavior.
Nit — coverage gap worth closing while here: the same literal-path hazard usually applies to the non-Windows branch (tar/unzip with odd filenames) and to any sibling helpers in this module interpolating paths into shell strings — a quick audit comment or follow-up ticket reference would lock the scope of the fix.
Overall: correct, minimal security/robustness fix with a test that exercises exactly the reported pathology (apostrophes + brackets in archive and destination names) end-to-end via real PowerShell. Nice. Thanks!
AI code review — automated review for reference; please use your judgment.
packages/opencode/src/util/archive.ts:9 — strong fix: moving paths out of the interpolated command string into env vars eliminates both the literal-path breakage (', [, ] in names) and a PowerShell injection vector the old quoting had. -LiteralPath is the right parameter.
packages/opencode/test/util/archive.test.ts:7 — good regression case with apostrophes and brackets in both source and destination names. Since the body early-returns off-Windows, confirm Windows CI actually runs this suite, otherwise it's dead coverage locally.
Nit: consider asserting that a malicious-looking name like foo'; Remove-Item -Recurse ~; 'bar.zip also extracts safely — that's the property this fix really guarantees.
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
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.
Issue for this PR
Closes #43036
Type of change
What does this PR do?
Pass Windows archive and destination paths through child-process environment variables instead of interpolating them into a PowerShell command.
It also switches
Expand-Archivefrom-Pathto-LiteralPath. This preserves apostrophes in valid paths and prevents characters such as[and]from being interpreted as wildcards.A Windows regression test covers archive and destination paths containing both kinds of characters.
How did you verify your code works?
bun test test/utilarchive's [copy].zipanddestination's [copy]Screenshots / recordings
N/A — this is a non-UI change.
Checklist