Prerequisites
Steps to reproduce
@'
function Test-Broken {
<#
.SYNOPSIS
A synopsis.
.EXAMPLE
Get-Something
#>
[CmdletBinding()] param()
}
'@ | Set-Content Broken.psm1
Import-Module ./Broken.psm1
New-CommandHelp -CommandInfo (Get-Command Test-Broken)
Expected behavior
A `CommandHelp` object is returned (with an empty description) — or, at worst, a per-command non-terminating error so the remaining commands in a pipeline batch still generate.
Actual behavior
`New-CommandHelp` throws. Adding a `.DESCRIPTION` makes it work. The error is statement-terminating, so one under-documented command loses the entire pipeline batch.
Error details
New-CommandHelp: The best overloaded method match for 'string.IsNullOrEmpty(string)' has some invalid arguments
Root cause in `TransformBase.cs`:
if (string.IsNullOrEmpty(GetStringFromDescriptionArray(helpItem.description)) &&
string.IsNullOrEmpty(helpItem.examples))
`helpItem.examples` is a PSObject (not a string) whenever examples exist, so the second operand throws — but only when the description is empty, because the `&&` short-circuits otherwise. That is why well-documented modules never see it.
Suggested fix: null-check `helpItem.examples` instead of `string.IsNullOrEmpty()`, and consider reporting a per-command non-terminating error so the remaining commands still generate.
Environment data
- Microsoft.PowerShell.PlatyPS 1.0.2
- PowerShell 7.5.8
Version
1.0.2
Visuals
No response
Additionally
Found while migrating Alt3.Docusaurus.Powershell to the v2 pipeline; downstream tracking: alt3/Docusaurus.Powershell#247
Prerequisites
Steps to reproduce
Expected behavior
A `CommandHelp` object is returned (with an empty description) — or, at worst, a per-command non-terminating error so the remaining commands in a pipeline batch still generate.Actual behavior
`New-CommandHelp` throws. Adding a `.DESCRIPTION` makes it work. The error is statement-terminating, so one under-documented command loses the entire pipeline batch.Error details
Environment data
Version
1.0.2
Visuals
No response
Additionally
Found while migrating Alt3.Docusaurus.Powershell to the v2 pipeline; downstream tracking: alt3/Docusaurus.Powershell#247