Skip to content

fix(events): degrade ps variant to 'no argv' when no pwsh/powershell on PATH - #7

Merged
kanfil merged 1 commit into
mainfrom
fix/dispatcher-ps-launcher-fallback
Aug 30, 2026
Merged

kanfil merged 1 commit into
mainfrom
fix/dispatcher-ps-launcher-fallback

Conversation

@kanfil

@kanfil kanfil commented Aug 29, 2026

Copy link
Copy Markdown
Member

Summary

Ports upstream spec-kit #4340 to the JS dispatcher.

resolveScriptArgv's ps branch unconditionally returned ["pwsh", "-File", …] — without probing PATH. On a host without pwsh/powershell, spawnSync raises ENOENT ("No such file or directory: 'pwsh'") instead of the clean "unresolvable, falling back" every other branch gets.

Fix

  • Add findLauncher() — a shutil.which mirror (PATH scan, PATHEXT on Windows, X_OK on POSIX).
  • ps branch now returns null when neither launcher resolves, so main() degrades to body injection / fail-open.

Test

  • New regression test in tests/events.test.mjs: ps-only skill with scrubbed PATH → asserts exit 0, the "unresolvable" warning, no ENOENT/script error, and body-injection fallback.
  • Test-the-test: with the fix reverted to the old ["pwsh", …] line, the test fails (status null / ENOENT).

Full suite: 108/108 pass.

Note: spec-kit #3857 (stdin .eof crash) was reviewed alongside and is not applicable — the JS readPayload reads raw bytes into a Buffer, detects EOF via n === 0, and fail-open truncates oversized payloads.

…on PATH

Mirrors spec-kit #4340. resolveScriptArgv's ps branch unconditionally
returned ['pwsh', '-File', ...] — without probing PATH, spawnSync would
raise ENOENT (confusing 'No such file or directory: pwsh') instead of the
clean 'unresolvable, falling back' every other branch gets.

Add a findLauncher() helper (shutil.which mirror: PATH scan, PATHEXT on
Windows, X_OK on POSIX) and return null when neither pwsh nor powershell
resolves, so main() degrades to body injection / fail-open.

Add a regression test that scrubs PATH for the child (parent uses
process.execPath) and asserts exit 0, the unresolvable warning, no
ENOENT/script error, and body-injection fallback.
@kanfil
kanfil merged commit 45a5c85 into main Aug 30, 2026
9 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants