René's URL Explorer Experiment


Title: Invoke-ScriptAnalyzer fails intermittently with NullReferenceException in CommandInfo.ResolveParameter (ProvideCommentHelp / AvoidReservedCharInCmdlet race on Export-ModuleMember) · Issue #2229 · PowerShell/PSScriptAnalyzer · GitHub

Open Graph Title: Invoke-ScriptAnalyzer fails intermittently with NullReferenceException in CommandInfo.ResolveParameter (ProvideCommentHelp / AvoidReservedCharInCmdlet race on Export-ModuleMember) · Issue #2229 · PowerShell/PSScriptAnalyzer

X Title: Invoke-ScriptAnalyzer fails intermittently with NullReferenceException in CommandInfo.ResolveParameter (ProvideCommentHelp / AvoidReservedCharInCmdlet race on Export-ModuleMember) · Issue #2229 · PowerShell/PSScriptAnalyzer

Description: Summary Invoke-ScriptAnalyzer fails intermittently on a file that calls Export-ModuleMember -Function .... The whole call fails with a RULE_ERROR. Usually the exception is a NullReferenceException in System.Management.Automation.CommandI...

Open Graph Description: Summary Invoke-ScriptAnalyzer fails intermittently on a file that calls Export-ModuleMember -Function .... The whole call fails with a RULE_ERROR. Usually the exception is a NullReferenceException ...

X Description: Summary Invoke-ScriptAnalyzer fails intermittently on a file that calls Export-ModuleMember -Function .... The whole call fails with a RULE_ERROR. Usually the exception is a NullReferenceException ...

Opengraph URL: https://github.com/PowerShell/PSScriptAnalyzer/issues/2229

X: @github

direct link

Domain: github.com


Hey, it has json ld scripts:
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Invoke-ScriptAnalyzer fails intermittently with NullReferenceException in CommandInfo.ResolveParameter (ProvideCommentHelp / AvoidReservedCharInCmdlet race on Export-ModuleMember)","articleBody":"## Summary\n\n`Invoke-ScriptAnalyzer` fails intermittently on a file that calls `Export-ModuleMember -Function ...`. The whole call fails with a `RULE_ERROR`. Usually the exception is a `NullReferenceException` in `System.Management.Automation.CommandInfo.ResolveParameter`. Less often it is an `InvalidOperationException` from `PSLocalEventManager.SubscribeEvent` (\"You cannot have more than one dynamic module in each dynamic assembly in this version of the runtime.\").\n\n## Environment\n\n- PSScriptAnalyzer 1.25.0\n- PowerShell 7.6.5 (pwsh)\n- Windows 11 Enterprise (x64)\n- Each run is a fresh `pwsh -NoProfile -NonInteractive` process. No profile, no other modules.\n\n## Minimal repro\n\n1. Create a folder with one file, `Probe.psm1`:\n\n   ```powershell\n   function Get-Probe { 'probe' }\n   Export-ModuleMember -Function Get-Probe\n   ```\n\n2. Run the analyzer in a fresh process, several times:\n\n   ```powershell\n   $fixture = '\u003cpath to the folder>'\n   $child = @\"\n   `$ErrorActionPreference = 'Stop'\n   try {\n       Import-Module PSScriptAnalyzer -Force\n       `$r = @(Invoke-ScriptAnalyzer -Path '$fixture' -Recurse)\n       \"OK count=`$(`$r.Count)\"\n   }\n   catch { \"EXC: `$(`$_.Exception.GetType().FullName): `$(`$_.Exception.Message)\"; exit 3 }\n   \"@\n   1..15 | ForEach-Object { pwsh -NoProfile -NonInteractive -Command $child }\n   ```\n\nA second fixture adds a class file beside the module (`ProbeBox.ps1`: `class ProbeBox { [NoSuchProbeType] $Value }`). It fails at a similar rate. The class file is not needed to trigger the fault.\n\n## Expected\n\nEvery run completes and returns the same findings (here: 1 finding).\n\n## Actual\n\nSome runs fail. The whole `Invoke-ScriptAnalyzer` call ends with `FullyQualifiedErrorId: RULE_ERROR,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerCommand`.\n\nStack, variant 1 (most frequent; the rule frame is `ProvideCommentHelp` or\n`AvoidReservedCharInCmdlet`):\n\n```\nSystem.NullReferenceException: Object reference not set to an instance of an object.\n   at System.Management.Automation.CommandInfo.ResolveParameter(String name)\n   at Microsoft.Windows.PowerShell.ScriptAnalyzer.Helper.GetExportedFunction(Ast ast)\n   at Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.AvoidReservedCharInCmdlet.AnalyzeScript(Ast ast, String fileName)+MoveNext()\n   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)\n   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)\n   at Microsoft.Windows.PowerShell.ScriptAnalyzer.ScriptAnalyzer.\u003c>c__DisplayClass84_1.\u003cAnalyzeSyntaxTree>b__2()\n```\n\nStack, variant 2:\n\n```\nSystem.InvalidOperationException: You cannot have more than one dynamic module in each dynamic assembly in this version of the runtime.\n   at System.Reflection.Emit.RuntimeAssemblyBuilder.DefineDynamicModuleCore(String name)\n   at System.Management.Automation.PSLocalEventManager.ProcessNewSubscriber(PSEventSubscriber subscriber, Object source, String eventName, String sourceIdentifier, PSObject data, Boolean supportEvent, Boolean forwardEvent)\n   at System.Management.Automation.PSLocalEventManager.SubscribeEvent(Object source, String eventName, String sourceIdentifier, PSObject data, PSEventReceivedEventHandler handlerDelegate, Boolean supportEvent, Boolean forwardEvent, Int32 maxTriggerCount)\n   at System.Management.Automation.PSLocalEventManager.SubscribeEvent(Object source, String eventName, String sourceIdentifier, PSObject data, PSEventReceivedEventHandler handlerDelegate, Boolean supportEvent, Boolean forwardEvent, Boolean shouldQueueAndProcessInExecutionThread, Int32 maxTriggerCount)\n   at System.Management.Automation.CommandInfo.GetMergedCommandParameterMetadataSafely()\n   at System.Management.Automation.CommandInfo.ResolveParameter(String name)\n   at Microsoft.Windows.PowerShell.ScriptAnalyzer.Helper.GetExportedFunction(Ast ast)\n   at Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.ProvideCommentHelp.AnalyzeScript(Ast ast, String fileName)+MoveNext()\n   at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)\n   at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)\n   at Microsoft.Windows.PowerShell.ScriptAnalyzer.ScriptAnalyzer.\u003c>c__DisplayClass84_1.\u003cAnalyzeSyntaxTree>b__2()\n```\n\n## Frequency\n\n| Target | Runs | Failed |\n|---|---|---|\n| Minimal module above (`Export-ModuleMember -Function`) | 15 | 6 (4 NullReferenceException, 2 InvalidOperationException) |\n| Minimal module plus a class file | 30 | 8 |\n| A real multi-file module (one `Export-ModuleMember` call), `-Recurse` | 25 | 4 |\n\nThe same module, signed or unsigned, fails at about the same rate.\n\n## Analysis\n\n- The analyzer runs the rules for one file in parallel, one task per rule.\n- `ProvideCommentHelp` (`PSProvideCommentHelp`) and `AvoidReservedCharInCmdlet` (`PSReservedCmdletChar`) both call `Helper.GetExportedFunction`. In 1.25.0 no other caller exists.\n- `GetExportedFunction` calls `CommandInfo.ResolveParameter` on the cached `Export-ModuleMember` `CmdletInfo`. That object belongs to a runspace of the analyzer's own pool. The call comes from the rule's thread pool thread.\n- PowerShell sends such a cross-thread call through a one-shot engine event (`GetMergedCommandParameterMetadataSafely`). That path does not support two concurrent callers. So one rule gets a null result (variant 1), or the two subscriptions collide (variant 2).\n\nA possible fix: resolve the `Export-ModuleMember` parameter metadata once, on the runspace thread, or serialize `GetExportedFunction` across rules.\n\n## Workaround\n\nRun the two rules in their own passes, so that nothing else uses the analyzer's runspace at the same time:\n\n```powershell\n$isolated = 'PSProvideCommentHelp', 'PSReservedCmdletChar'\n$r  = @(Invoke-ScriptAnalyzer -Path $path -Recurse -ExcludeRule $isolated)\nforeach ($rule in $isolated) {\n    # Keep only that rule's findings: each pass reports the parse diagnostics again.\n    $r += @(Invoke-ScriptAnalyzer -Path $path -Recurse -IncludeRule $rule |\n        Where-Object RuleName -eq $rule)\n}\n```\n\nWith the workaround: 0 failures in 40 runs of the minimal module, 0 in 30 runs of the module with a class file, and 0 in 15 runs over three real modules. The findings are the same as those of a complete single pass.","author":{"url":"https://github.com/ondrejtucny","@type":"Person","name":"ondrejtucny"},"datePublished":"2026-10-19T18:23:21Z","url":"https://github.com/PowerShell/PSScriptAnalyzer/issues/2229"}

react-profiling0
react-import-mapreact,react-dom,react-dom/client,react-dom/profiling,react-is,react/compiler-runtime,react/jsx-dev-runtime,react/jsx-runtime,scheduler@b8488ee2c322
route-pattern/_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format)
route-controllervoltron_issues_fragments
route-actionissue_layout
fetch-noncev2:5c46d723-2d81-acf5-436e-d574d66a6614
current-catalog-service-hash81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114
request-idEDF0:C0CAB:6E7C:92EA:6AFCD7B4
html-safe-noncecbb256d03c8fad8a3b505572f362c478a75af56690d8a3e0eadd3bcb8fd000a4
visitor-payloadeyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFREYwOkMwQ0FCOjZFN0M6OTJFQTo2QUZDRDdCNCIsInZpc2l0b3JfaWQiOiI1ODU0ODk4Njg1MjYyNzQ3NTcyIiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0=
visitor-hmacf51e5acac52722370d0955b835804b37e970bfe33da8b51bd37432024d95eb7a
hovercard-subject-tagissue:5929230172
github-keyboard-shortcutsrepository,issues,copilot
google-site-verificationApib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I
octolytics-urlhttps://collector.github.com/github/collect
analytics-location///voltron/issues_fragments/issue_layout
fb:app_id1401488693436528
apple-itunes-appapp-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PSScriptAnalyzer/2229/issue_layout
twitter:imagehttps://opengraph.githubassets.com/b7b73e082a634084f6b087e743bdcd733562213737a31573e3253533967e8c9b/PowerShell/PSScriptAnalyzer/issues/2229
twitter:cardsummary_large_image
og:imagehttps://opengraph.githubassets.com/b7b73e082a634084f6b087e743bdcd733562213737a31573e3253533967e8c9b/PowerShell/PSScriptAnalyzer/issues/2229
og:image:altSummary Invoke-ScriptAnalyzer fails intermittently on a file that calls Export-ModuleMember -Function .... The whole call fails with a RULE_ERROR. Usually the exception is a NullReferenceException ...
og:image:width1200
og:image:height600
og:site_nameGitHub
og:typeobject
og:author:usernameondrejtucny
hostnamegithub.com
expected-hostnamegithub.com
Noneb5b7bc7e41e0a604bbdb5035c7ed9620c2d28b9c8a18747182e2262a75abfd91
turbo-cache-controlno-preview
go-importgithub.com/PowerShell/PSScriptAnalyzer git https://github.com/PowerShell/PSScriptAnalyzer.git
octolytics-dimension-user_id11524380
octolytics-dimension-user_loginPowerShell
octolytics-dimension-repository_id33149177
octolytics-dimension-repository_nwoPowerShell/PSScriptAnalyzer
octolytics-dimension-repository_publictrue
octolytics-dimension-repository_is_forkfalse
octolytics-dimension-repository_network_root_id33149177
octolytics-dimension-repository_network_root_nwoPowerShell/PSScriptAnalyzer
turbo-body-classeslogged-out env-production page-responsive
disable-turbofalse
browser-stats-urlhttps://api.github.com/_private/browser/stats
browser-errors-urlhttps://api.github.com/_private/browser/errors
releaseff5022cc3aa767e6115451d9c322dd975506d40e
ui-targetcanary-2
theme-color#1e2327
color-schemelight dark
react-app-nameissues

Links:

Skip to contenthttps://github.com/PowerShell/PSScriptAnalyzer/issues/2229#start-of-content
https://github.com/
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPSScriptAnalyzer%2Fissues%2F2229
GitHubRepository hosting, code review, and collaborationhttps://github.com/platform
CopilotAI coding agent for tasks, projects, and automated workhttps://github.com/features/copilot
ActionsCI/CD and automationhttps://github.com/features/actions
Code QualityQuality analysis, fixes, and enforcementhttps://github.com/features/code-quality
CodespacesCloud development environmentshttps://github.com/features/codespaces
Code SecurityVulnerability detection and remediationhttps://github.com/security/advanced-security/code-security
Secret ProtectionSecret scanning and leak preventionhttps://github.com/security/advanced-security/secret-protection
All Featureshttps://github.com/features
Documentationhttps://docs.github.com/en
Traininghttps://learn.github.com/skills
Certificationshttps://learn.github.com/credentials
Build with Copilothttps://github.com/features/ai
Customize Copilothttps://docs.github.com/en/copilot/how-tos/copilot-on-github/customize-copilot/customize-copilot-overview
Integrationshttps://github.com/marketplace
Trending reposhttps://github.com/trending
GitHub Sponsorshttps://github.com/open-source/sponsors
Developer articleshttps://github.com/resources/articles
ChangelogYour source for the latest features, improvements, and fixes across GitHub products, all in one place.https://github.blog/changelog/
Enterpriseshttps://github.com/enterprise
Teamhttps://github.com/team
Startupshttps://github.com/enterprise/startups
Nonprofitshttps://github.com/solutions/industry/nonprofits
Healthcarehttps://github.com/solutions/industry/healthcare
Financial serviceshttps://github.com/solutions/industry/financial-services
Manufacturinghttps://github.com/solutions/industry/manufacturing
Governmenthttps://github.com/solutions/industry/government
See all industrieshttps://github.com/solutions/industry
Why GitHubhttps://github.com/why-github
Customer Storieshttps://github.com/customer-stories
Business insightshttps://github.com/solutions/executive-insights
Trust Centerhttps://github.com/trust-center
GitHub Advanced SecurityEnterprise-grade code securityhttps://github.com/security/advanced-security
Copilot for businessEnterprise-grade AI featureshttps://github.com/features/copilot/copilot-business
Premium SupportEnterprise-grade 24/7 supporthttps://github.com/enterprise/premium-support
Documentationhttps://docs.github.com/en
Resource centerhttps://github.com/resources
Bloghttps://github.blog/
Events & webinarshttps://github.com/resources/events
Community Forumhttps://github.com/orgs/community/discussions
Customer Storieshttps://github.com/customer-stories
Integrationshttps://github.com/marketplace
Customer supporthttps://help.github.com/
Traininghttps://learn.github.com/skills
GitHub Statushttps://www.githubstatus.com/
Abouthttps://github.com/about
Partnershttps://github.com/partners
Changeloghttps://github.blog/changelog/
GitHub UniverseThe event for developers, by developers — talks, workshops, and what’s next for GitHub.https://githubuniverse.com/
Pricinghttps://github.com/pricing
Sign inhttps://github.com/login?return_to=https%3A%2F%2Fgithub.com%2FPowerShell%2FPSScriptAnalyzer%2Fissues%2F2229
Sign uphttps://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E%2Fvoltron%2Fissues_fragments%2Fissue_layout&source=header-repo&source_repo=PowerShell%2FPSScriptAnalyzer
Reloadhttps://github.com/PowerShell/PSScriptAnalyzer/issues/2229
Reloadhttps://github.com/PowerShell/PSScriptAnalyzer/issues/2229
Reloadhttps://github.com/PowerShell/PSScriptAnalyzer/issues/2229
PowerShellhttps://github.com/PowerShell
PSScriptAnalyzerhttps://github.com/PowerShell/PSScriptAnalyzer
Codehttps://github.com/PowerShell/PSScriptAnalyzer
Issues407 (407)https://github.com/PowerShell/PSScriptAnalyzer/issues
Pull requests34 (34)https://github.com/PowerShell/PSScriptAnalyzer/pulls
Discussionshttps://github.com/PowerShell/PSScriptAnalyzer/discussions
Actionshttps://github.com/PowerShell/PSScriptAnalyzer/actions
Projectshttps://github.com/PowerShell/PSScriptAnalyzer/projects
Wikihttps://github.com/PowerShell/PSScriptAnalyzer/wiki
Security and qualityhttps://github.com/PowerShell/PSScriptAnalyzer/security
Insightshttps://github.com/PowerShell/PSScriptAnalyzer/insights
https://github.com/PowerShell/PSScriptAnalyzer
New issuehttps://github.com/login?return_to=https://github.com/PowerShell/PSScriptAnalyzer/issues/2229
New issuehttps://github.com/login?return_to=https://github.com/PowerShell/PSScriptAnalyzer/issues/2229
#2206https://github.com/PowerShell/PSScriptAnalyzer/pull/2206
Invoke-ScriptAnalyzer fails intermittently with NullReferenceException in CommandInfo.ResolveParameter (ProvideCommentHelp / AvoidReservedCharInCmdlet race on Export-ModuleMember)https://github.com/PowerShell/PSScriptAnalyzer/issues/2229#top
#2206https://github.com/PowerShell/PSScriptAnalyzer/pull/2206
Issue - Bughttps://github.com/PowerShell/PSScriptAnalyzer/issues?q=state%3Aopen%20label%3A%22Issue%20-%20Bug%22
https://github.com/ondrejtucny
Ondřej Tučný (ondrejtucny)https://github.com/ondrejtucny
on Oct 19, 2026https://github.com/PowerShell/PSScriptAnalyzer/issues/2229#issue-5929230172
Christoph Bergmeister (bergmeister)https://github.com/bergmeister
Issue - Bughttps://github.com/PowerShell/PSScriptAnalyzer/issues?q=state%3Aopen%20label%3A%22Issue%20-%20Bug%22
on Oct 22, 2026https://github.com/PowerShell/PSScriptAnalyzer/issues/2229#event-33996466121
https://github.com/bergmeister
Christoph Bergmeister (bergmeister)https://github.com/bergmeister
on Oct 22, 2026https://github.com/PowerShell/PSScriptAnalyzer/issues/2229#issuecomment-6351966132
#2206https://github.com/PowerShell/PSScriptAnalyzer/pull/2206
https://github.com/ChrisTX
Christian Pfeiffer (ChrisTX)https://github.com/ChrisTX
on Nov 1, 2026https://github.com/PowerShell/PSScriptAnalyzer/issues/2229#issuecomment-6552206445
#2206https://github.com/PowerShell/PSScriptAnalyzer/pull/2206
#2206https://github.com/PowerShell/PSScriptAnalyzer/pull/2206
Arch Linux Technical User (archlinux-github)https://github.com/archlinux-github
on Nov 1, 2026https://github.com/PowerShell/PSScriptAnalyzer/issues/2229#event-34851696505
upgpkg: powershell-editor-services 4.7.0-6https://github.com/archlinux/aur/commit/c69168dd70c6817b84dfa6706074305c6887b3e2
c69168dhttps://github.com/archlinux/aur/commit/c69168dd70c6817b84dfa6706074305c6887b3e2
https://github.com/jessehouwing
Jesse Houwing (jessehouwing)https://github.com/jessehouwing
on Nov 1, 2026https://github.com/PowerShell/PSScriptAnalyzer/issues/2229#issuecomment-6565568587
#2206https://github.com/PowerShell/PSScriptAnalyzer/pull/2206
https://github.com/jessehouwing
Jesse Houwing (jessehouwing)https://github.com/jessehouwing
on Nov 1, 2026https://github.com/PowerShell/PSScriptAnalyzer/issues/2229#issuecomment-6565609383
Christoph Bergmeister (@bergmeister)https://github.com/bergmeister
#2206https://github.com/PowerShell/PSScriptAnalyzer/pull/2206
https://github.com/ChrisTX
Christian Pfeiffer (ChrisTX)https://github.com/ChrisTX
on Nov 5, 2026https://github.com/PowerShell/PSScriptAnalyzer/issues/2229#issuecomment-6671573908
Christoph Bergmeister (@bergmeister)https://github.com/bergmeister
#2206https://github.com/PowerShell/PSScriptAnalyzer/pull/2206
Jesse Houwing (@jessehouwing)https://github.com/jessehouwing
https://github.com/bergmeister
Christoph Bergmeister (bergmeister)https://github.com/bergmeister
on Nov 5, 2026https://github.com/PowerShell/PSScriptAnalyzer/issues/2229#issuecomment-6671619078
Christoph Bergmeister (@bergmeister)https://github.com/bergmeister
#2206https://github.com/PowerShell/PSScriptAnalyzer/pull/2206
Jesse Houwing (@jessehouwing)https://github.com/jessehouwing
Sign up for freehttps://github.com/signup?return_to=https://github.com/PowerShell/PSScriptAnalyzer/issues/2229
Sign in to commenthttps://github.com/login?return_to=https://github.com/PowerShell/PSScriptAnalyzer/issues/2229
Issue - Bughttps://github.com/PowerShell/PSScriptAnalyzer/issues?q=state%3Aopen%20label%3A%22Issue%20-%20Bug%22
https://github.com
Termshttps://docs.github.com/site-policy/github-terms/github-terms-of-service
Privacyhttps://docs.github.com/site-policy/privacy-policies/github-privacy-statement
Securityhttps://github.com/security
Statushttps://www.githubstatus.com/
Communityhttps://github.community/
Docshttps://docs.github.com/
Contacthttps://support.github.com?tags=dotcom-footer

Viewport: width=device-width


URLs of crawlers that visited me.