Title: AvoidReservedCharInCmdlet throws System.NullReferenceException sometimes due to CommandInfo.ResolveParameter issue · Issue #1538 · PowerShell/PSScriptAnalyzer · GitHub
Open Graph Title: AvoidReservedCharInCmdlet throws System.NullReferenceException sometimes due to CommandInfo.ResolveParameter issue · Issue #1538 · PowerShell/PSScriptAnalyzer
X Title: AvoidReservedCharInCmdlet throws System.NullReferenceException sometimes due to CommandInfo.ResolveParameter issue · Issue #1538 · PowerShell/PSScriptAnalyzer
Description: I report this error although I cannot reproduce the bug, moreover the analyzed code is private :-/ The exception is random during a build via PSake. I already had this error with the previous version 1.8. The exception is most often rais...
Open Graph Description: I report this error although I cannot reproduce the bug, moreover the analyzed code is private :-/ The exception is random during a build via PSake. I already had this error with the previous versi...
X Description: I report this error although I cannot reproduce the bug, moreover the analyzed code is private :-/ The exception is random during a build via PSake. I already had this error with the previous versi...
Opengraph URL: https://github.com/PowerShell/PSScriptAnalyzer/issues/1538
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"AvoidReservedCharInCmdlet throws System.NullReferenceException sometimes due to CommandInfo.ResolveParameter issue","articleBody":"\r\nI report this error although I cannot reproduce the bug, moreover the analyzed code is private :-/\r\n\r\nThe exception is random during a build via PSake. I already had this error with the previous version 1.8.\r\nThe exception is most often raised when I open a powershell session and then execute my build script.\r\nWhen, after the triggering of the error, I relaunch my error script, I no longer have an error\r\n\r\nI have not yet had time to run only the PSSA command line.\r\n\r\n\r\nActual behavior\r\n---------------\r\n\r\n```none\r\n[STA] E:\\Projets\\xxxx> $error[0]|select *\r\n\r\n\r\nPSMessageDetails :\r\nException : System.NullReferenceException: Object reference not set to an instance of an object.\r\n at System.Management.Automation.CommandInfo.ResolveParameter(String name)\r\n at Microsoft.Windows.PowerShell.ScriptAnalyzer.Helper.GetExportedFunction(Ast ast)\r\n at Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.AvoidReservedCharInCmdlet.\u003cAnalyzeScript>d__0.MoveNext()\r\n at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)\r\n at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)\r\n at Microsoft.Windows.PowerShell.ScriptAnalyzer.ScriptAnalyzer.\u003c>c__DisplayClass83_1.\u003cAnalyze\r\n SyntaxTree>b__2()\r\nTargetObject : E:\\RELEASES\\xxx\\yyyy\\Modules\\Log4Posh\\Log4Posh.psm1\r\nCategoryInfo : InvalidOperation: (E:\\RELEASES\\xxx…\\Log4Posh.psm1:String) [Invoke-ScriptAnalyzer],\r\n NullReferenceException\r\nFullyQualifiedErrorId : RULE_ERROR,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerCommand\r\nErrorDetails :\r\nInvocationInfo : System.Management.Automation.InvocationInfo\r\nScriptStackTrace : at \u003cScriptBlock>, E:\\Projets\\xxx\\build.psake.ps1: line 154\r\n at Invoke-Task, E:\\...\\Modules\\psake\\4.9.0\\public\\Invoke-Task.ps1: line 108\r\n at Invoke-Task, E:\\...\\Modules\\psake\\4.9.0\\public\\Invoke-Task.ps1: line 84\r\n at \u003cScriptBlock>, E:\\...\\Modules\\psake\\4.9.0\\public\\Invoke-psake.ps1: line 303\r\n at ExecuteInBuildFileScope,\r\n E:\\...\\Modules\\psake\\4.9.0\\private\\ExecuteInBuildFileScope.ps1: line 57\r\n at Invoke-psake, E:\\...\\Modules\\psake\\4.9.0\\public\\Invoke-psake.ps1: line 258\r\n at \u003cScriptBlock>, E:\\Projets\\xxx\\build.ps1: line 14\r\n at \u003cScriptBlock>, \u003cNo file>: line 1\r\nPipelineIterationInfo : {}\r\n\r\n\r\n--OR\r\n\r\nPSMessageDetails :\r\nException : System.NullReferenceException: Object reference not set to an instance of an object.\r\n at System.Management.Automation.CommandInfo.ResolveParameter(String name)\r\n at Microsoft.Windows.PowerShell.ScriptAnalyzer.Helper.GetExportedFunction(Ast ast)\r\n at Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.AvoidReservedCharInCmdlet.\u003cAnalyzeScript>d__0.MoveNext()\r\n at System.Collections.Generic.List`1..ctor(IEnumerable`1 collection)\r\n at System.Linq.Enumerable.ToList[TSource](IEnumerable`1 source)\r\n at Microsoft.Windows.PowerShell.ScriptAnalyzer.ScriptAnalyzer.\u003c>c__DisplayClass83_1.\u003cAnalyze\r\n SyntaxTree>b__2()\r\nTargetObject : E:\\RELEASES\\XXX\\Modules\\YYY\\YYY.psm1\r\nCategoryInfo : InvalidOperation: (E:\\RELEASES\\xxx...yyyy.psm1:String) [Invoke-ScriptAnalyzer],\r\n NullReferenceException\r\nFullyQualifiedErrorId : RULE_ERROR,Microsoft.Windows.PowerShell.ScriptAnalyzer.Commands.InvokeScriptAnalyzerCommand\r\nErrorDetails :\r\nInvocationInfo : System.Management.Automation.InvocationInfo\r\nScriptStackTrace : at \u003cScriptBlock>, E:\\Projets\\xxx\\build.psake.ps1: line 154\r\n at Invoke-Task, E:\\SYSTOOLS\\XXX\\Modules\\psake\\4.9.0\\public\\Invoke-Task.ps1: line 108\r\n at Invoke-Task, E:\\SYSTOOLS\\XXX\\Modules\\psake\\4.9.0\\public\\Invoke-Task.ps1: line 84\r\n at \u003cScriptBlock>, E:\\SYSTOOLS\\XXX\\Modules\\psake\\4.9.0\\public\\Invoke-psake.ps1: line 303\r\n at ExecuteInBuildFileScope,\r\n E:\\SYSTOOLS\\XXX\\Modules\\psake\\4.9.0\\private\\ExecuteInBuildFileScope.ps1: line 57\r\n at Invoke-psake, E:\\SYSTOOLS\\XXX\\Modules\\psake\\4.9.0\\public\\Invoke-psake.ps1: line 258\r\n at \u003cScriptBlock>, E:\\Projets\\xxxs\\build.ps1: line 14\r\n at \u003cScriptBlock>, \u003cNo file>: line 1\r\nPipelineIterationInfo : {}\r\n\r\n```\r\nThe first three lines are always the same :\r\n```none\r\n\r\nException : System.NullReferenceException: Object reference not set to an instance of an object.\r\n at System.Management.Automation.CommandInfo.ResolveParameter(String name)\r\n at Microsoft.Windows.PowerShell.ScriptAnalyzer.Helper.GetExportedFunction(Ast ast)\r\n```\r\nThe fourth concerns a rule name which can be different :\r\n```none\r\n at Microsoft.Windows.PowerShell.ScriptAnalyzer.BuiltinRules.AvoidReservedCharInCmdlet.\u003cAnalyzeScript>d__0.MoveNext()\r\n```\r\nThe _TargetObject_ property points to a module of the project. The module may not have been modified for several days and may not trigger an error during the previous analysis (10 minutes ago)\r\n\r\nEnvironment data\r\n----------------\r\n\r\n```PowerShell\r\nv5.1 Windows server 2012\r\n\r\n> (Get-Module -ListAvailable PSScriptAnalyzer).Version | ForEach-Object { $_.ToString() }\r\nGet-Module\r\n\r\nModuleType Version Name ExportedCommands\r\n---------- ------- ---- ----------------\r\nManifest 3.1.0.0 Microsoft.PowerShell.Management {Add-Computer, Add-Content, Checkpoint-Computer, Clear-Con...\r\nManifest 3.1.0.0 Microsoft.PowerShell.Utility {Add-Member, Add-Type, Clear-Variable, Compare-Object, Con...\r\nScript 1.0.0.0 posh-git {Add-PoshGitToProfile, Expand-GitCommand, Format-GitBranch...\r\nScript 4.9.0 psake {Assert, Exec, FormatTaskName, Framework, Get-PSakeScriptT...\r\nScript 2.0.2 PSReadline {Get-PSReadLineKeyHandler, Get-PSReadLineOption, Remove-PS...\r\nScript 1.19.0 psscriptanalyzer {Get-ScriptAnalyzerRule, Invoke-Formatter, Invoke-ScriptAn...\r\n\r\n```\r\n\r\nTest without any error, performed after the error is triggered :\r\n```PowerShell\r\n[STA] E:\\Projets\\XXXs> $error.Clear(); cls;1..20|% {.\\build.ps1}\r\n```\r\nCommand line :\r\n```PowerShell\r\n$analysisResult = Invoke-ScriptAnalyzer -Path $ModuleOutDir -Settings $ScriptAnalyzerSettingsPath -Recurse -Verbose:($VerbosePreference -eq 'Continue')\r\n\r\n#Setting file \r\n@{\r\n ExcludeRules = @(\r\n 'PSAvoidGlobalVars', #Legacy\r\n 'PSAvoidUsingWMICmdlet', #Legacy\r\n 'PSAvoidUsingDeprecatedManifestFields',\r\n 'PSMissingModuleManifestField',\r\n 'PSUseToExportFieldsInManifest',\r\n 'PSUseUsingScopeModifierInNewRunspaces',\r\n 'PSReviewUnusedParameter'\r\n )\r\n\r\n # Check if the scripts uses cmdlets that are compatible PS 3.0,\r\n Rules = @{\r\n PSUseCompatibleCommands = @{\r\n # Turns the rule on\r\n Enable = $true\r\n\r\n # Lists the PowerShell platforms we want to check compatibility with\r\n TargetProfiles = @(\r\n #PowerShell Version 3.0 Operating System Windows Server 2012\r\n 'win-8_x64_6.2.9200.0_3.0_x64_4.0.30319.42000_framework'\r\n )\r\n }\r\n }\r\n}\r\n\r\n```\r\n\r\n","author":{"url":"https://github.com/LaurentDardenne","@type":"Person","name":"LaurentDardenne"},"datePublished":"2020-07-02T16:22:13Z","url":"https://github.com/PowerShell/PSScriptAnalyzer/issues/1538"}
| react-profiling | 0 |
| react-import-map | react,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-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:cb79f26d-6052-86f4-b17d-a7fae40d22bc |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E036:285430:8155A6:B24A47:6AFD2D3D |
| html-safe-nonce | 0150663fdb5f5eb5400a003394fd17e2bfcaaece536c9bcf27c7ad6705302796 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFMDM2OjI4NTQzMDo4MTU1QTY6QjI0QTQ3OjZBRkQyRDNEIiwidmlzaXRvcl9pZCI6Ijc1OTkwNjc3NjcyNDg4NTg0MjkiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | de5b7a9bc579e0ff0e2e1e392138b222d5c9cbc5728727bd85e6ed645834a1a3 |
| hovercard-subject-tag | issue:650058760 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/PowerShell/PSScriptAnalyzer/1538/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ba394a50f9313aedc6a8e2cb664b9257891054d183f2b43846290e15e7defc27/PowerShell/PSScriptAnalyzer/issues/1538 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ba394a50f9313aedc6a8e2cb664b9257891054d183f2b43846290e15e7defc27/PowerShell/PSScriptAnalyzer/issues/1538 |
| og:image:alt | I report this error although I cannot reproduce the bug, moreover the analyzed code is private :-/ The exception is random during a build via PSake. I already had this error with the previous versi... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | LaurentDardenne |
| hostname | github.com |
| expected-hostname | github.com |
| None | 065128366c233a9d57ff68ab6c96e25b99dd1b0ab70d23b70873d3dd6b5e4f19 |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PSScriptAnalyzer git https://github.com/PowerShell/PSScriptAnalyzer.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 33149177 |
| octolytics-dimension-repository_nwo | PowerShell/PSScriptAnalyzer |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 33149177 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PSScriptAnalyzer |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 941021edf0c2ec58298f4a2c8f27ae507d129c92 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width