Skip to content

fix(cli): guard PowerShell process queries against exited PIDs - #3571

Merged
miguel-heygen merged 2 commits into
mainfrom
fix/windows-powershell-null-guard
Aug 31, 2026
Merged

fix(cli): guard PowerShell process queries against exited PIDs#3571
miguel-heygen merged 2 commits into
mainfrom
fix/windows-powershell-null-guard

Conversation

@miga-heygen

Copy link
Copy Markdown
Contributor

Summary

processIdentity and processParentPid call Get-CimInstance Win32_Process to look up process metadata on Windows. When the target process has already exited, Get-CimInstance returns null and calling .CreationDate.ToFileTimeUtc() or .ParentProcessId on it throws InvokeMethodOnNull. The try/catch handles it, but PowerShell writes the error to stderr, which pollutes the test runner's output and causes spurious exit code 1 on Windows CI.

Two fixes per call site:

  • Null-check the CimInstance before accessing properties ($p = ...; if ($p) { $p.Property })
  • -ErrorAction SilentlyContinue + stdio: ["pipe", "pipe", "ignore"] to suppress any residual stderr

Fixes the recurring Tests on windows-latest flake on main.

Test plan

  • All 196 CLI test files pass locally
  • Windows CI should no longer exit 1 from PowerShell stderr noise

— Miga

The squash merge of #3518 (content tools) re-introduced the old test
assertion that document.modelContext is absent. The polyfill from #3514
installs it as a fallback — that is expected behavior.

Same fix as #3532: remove the assertion, keep the boot-cleanly contract.

Fixes CI Test failure on main.
Get-CimInstance returns null when the target process has already exited.
Calling .CreationDate or .ParentProcessId on null throws
InvokeMethodOnNull, which writes to stderr even though the try/catch
handles it. On Windows CI this stderr noise pollutes the test runner's
output and can cause spurious exit code 1.

Two fixes:
- Null-check the CimInstance before accessing properties
- ErrorAction SilentlyContinue + stdio stderr suppression

Fixes CI 'Tests on windows-latest' flake on main.
@miguel-heygen
miguel-heygen merged commit 73aa71c into main Aug 31, 2026
47 checks passed

Copy link
Copy Markdown
Collaborator

Merge activity

@miguel-heygen
miguel-heygen deleted the fix/windows-powershell-null-guard branch August 31, 2026 21:15
@miguel-heygen miguel-heygen mentioned this pull request Aug 31, 2026
5 tasks
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