fix(machine-health): drop Export-ModuleMember from Mock-Helpers - #4374
Merged
Merged
Conversation
PSScriptAnalyzer 1.25.0 intermittently throws a NullReferenceException on files that call Export-ModuleMember: rules run in parallel and share a cached CommandInfo (PowerShell/PSScriptAnalyzer#1867, #2188; fix pending in PR #2206). Without the call a .psm1 exports every function it defines, and this module exports all 14 of its functions, so the exported set is unchanged. Refs melodic-software/standards#598 Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XJ1oJNVZ9BySCtLzdJtf25
kyle-sexton
marked this pull request as ready for review
September 23, 2026 17:28
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
Skill evidence: a gap at
|
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01XJ1oJNVZ9BySCtLzdJtf25
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
No related issue: org-wide follow-up to melodic-software/standards#598, which stays open in standards
Summary
Removes
Export-ModuleMemberfrom the machine-health test helperMock-Helpers.psm1. On files that call it, PSScriptAnalyzer 1.25.0 intermittently throws aNullReferenceException:Helper.GetExportedFunctioncallsCommandInfo.ResolveParameteron a shared cachedCommandInfowhile rules run in parallel (PowerShell/PSScriptAnalyzer#1867, #2188; fix pending in PR #2206).Fix
Deleted the trailing
Export-ModuleMember -Function @(...)block. Without it a script module exports every function it defines, and this module exported all 14 of its functions, so the exported set does not change. machine-health is bumped to 0.13.1 with a changelog entry. The lint gate stays fail-closed with no retry (decision on melodic-software/standards#598).Verification
(Import-Module ./Mock-Helpers.psm1 -PassThru -Force).ExportedCommands.Keys: the same 14 functions (New-MachineHealthTempDir,New-MockBattery,New-MockDefenderComputerStatus,New-MockDriver,New-MockEnvironmentKey,New-MockEventLogRecord,New-MockPartition,New-MockPhysicalDisk,New-MockReliabilityCounter,New-MockReliabilityRecord,New-MockReliabilityStabilityMetric,New-MockService,New-MockVolume,Remove-MachineHealthTempDir).Invoke-ScriptAnalyzeron the file, one freshpwshper run: main threw in 3 of 10 runs (the surfaced error was the NRE); this branch threw in 0 of 20. The finding count is unchanged (14, all default-ruleset warnings that predate this change).Invoke-MachineHealthTests.ps1: 443 passed, 1 failed, 1 skipped on both main and this branch. The one failure (Test-EnvironmentHealth"expands %VAR% before existence and scope checks") reads this machine's environment and fails identically on main.gh pr readyfrom a worker session; the change is a 17-line deletion plus a version bump, verified by the export and PSScriptAnalyzer checks above.Related
🤖 Generated with Claude Code
https://claude.ai/code/session_01XJ1oJNVZ9BySCtLzdJtf25