Skip to content

fix(cli): skip undefined Windows env entries and guard empty spawn fallbacks - #2712

Open
Pybsama wants to merge 1 commit into
getsentry:mainfrom
Pybsama:fix/windows-spawn-undefined-env-and-empty-fallbacks
Open

Pybsama wants to merge 1 commit into
getsentry:mainfrom
Pybsama:fix/windows-spawn-undefined-env-and-empty-fallbacks

Conversation

@Pybsama

@Pybsama Pybsama commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Ignore undefined values in windowsEnvKey() so case-insensitive Windows environment lookups match Node's child_process.spawn behavior (which omits undefined entries). Previously, an env object containing { PATH: undefined, Path: "..." } sorted "PATH" ahead of "Path", causing resolveSpawnTarget() to miss Path/PATHEXT/ComSpec and augmentPathForNode() to discard the existing Path value.
  • Return undefined early in resolveWindowsCommand() when command is empty so "" cannot match a PATHEXT dotfile (such as .cmd) on PATH.
  • Fall back to DEFAULT_PATHEXT when PATHEXT is empty (or contains only empty segments) and to "cmd.exe" when ComSpec is empty.
  • Add unit tests in packages/cli/test/lib/windows-spawn.test.ts.

Verification

  • pnpm --filter sentry lint (oxlint + oxfmt --check)
  • pnpm --filter sentry typecheck
  • (cd packages/cli && TZ=UTC ./node_modules/.bin/vitest run test/lib/windows-spawn.test.ts test/lib/spawn-failure.test.ts) (2 files, 22/22 passed)
  • pnpm --filter @sentry/mcp-server bundle && pnpm --filter @sentry/mcp-server test:bundle (26/26 passed)

…llbacks

Ignore keys with undefined values in windowsEnvKey so Node's spawn
behavior is matched when env objects contain both e.g. PATH: undefined
and Path: ..., preventing resolveSpawnTarget and augmentPathForNode from
losing the defined variable. Also avoid resolving an empty command
string against PATHEXT dotfiles, and fall back to defaults when PATHEXT
or ComSpec is set to an empty string.

Co-Authored-By: Antigravity <noreply@google.com>
@vercel

vercel Bot commented Dec 1, 2026

Copy link
Copy Markdown

Someone is attempting to deploy a commit to the Sentry Team on Vercel.

A member of the Team first needs to authorize it.

@vercel
vercel Bot temporarily deployed to Preview – sentry-local December 1, 2026 21:38 Inactive
@vercel

vercel Bot commented Dec 1, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated
sentry-local Skipped Skipped Dec 1, 2026 9:38pm UTC

Request Review

@github-actions github-actions Bot added the risk: medium PR risk score: medium label Dec 1, 2026

This branch was previously deployed

1 inactive deployment
Preview – sentry-local — cf8682f7 Deployed Dec 1, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant