Skip to content

Export-YamlCommandHelp is serializing 'NULL' as empty string in acceptedValues #758

@sdwheeler

Description

@sdwheeler

Prerequisites

  • Write a descriptive title.
  • Make sure you are able to repro it on the latest released version
  • Search the existing issues.

Steps to reproduce

Resolve-DnsName.md

$c = Import-MarkdownCommandHelp -Path .\Resolve-DnsName.md
$c.parameters | where name -eq Type | select -exp AcceptedValues

Notice the value NULL appears in the list

$c | export-yamlCommandHelp -OutputFolder . -Force
$y = Import-YamlCommandHelp .\DnsClient\Resolve-DnsName.yml
Import-YamlCommandHelp: Object reference not set to an instance of an object.

Expected behavior

The value `NULL` needs to be wrapped in quotes `"NULL"` when converted to YAML.

Actual behavior

The value is being written without quotes so YAML treats it as the YAML null, not the string "NULL".

Error details

Exception             :
    Type       : System.NullReferenceException
    TargetSite :
        Name          : GetParameterFromDictionary
        DeclaringType : [Microsoft.PowerShell.PlatyPS.YamlUtils]
        MemberType    : Method
        Module        : Microsoft.PowerShell.PlatyPS.dll
    Message    : Object reference not set to an instance of an object.
    Source     : Microsoft.PowerShell.PlatyPS
    HResult    : -2147467261
    StackTrace :
   at Microsoft.PowerShell.PlatyPS.YamlUtils.GetParameterFromDictionary(Dictionary`2 pDictionary) in
D:\PSGit\platyps\src\Common\YamlUtils.cs:line 421
   at Microsoft.PowerShell.PlatyPS.YamlUtils.GetParametersFromDictionary(OrderedDictionary dictionary) in
D:\PSGit\platyps\src\Common\YamlUtils.cs:line 301
   at Microsoft.PowerShell.PlatyPS.YamlUtils.ConvertDictionaryToCommandHelp(OrderedDictionary dictionary) in
D:\PSGit\platyps\src\Common\YamlUtils.cs:line 236
   at Microsoft.PowerShell.PlatyPS.ImportYamlMetadataCommand.ProcessRecord() in
D:\PSGit\platyps\src\Command\ImportYamlCommand.cs:line 113
TargetObject          : D:\temp\platyps\broke\DnsClient\Resolve-DnsName.yml
CategoryInfo          : InvalidData: (D:\temp\platyps\bro…Resolve-DnsName.yml:String) [Import-YamlCommandHelp],
NullReferenceException
FullyQualifiedErrorId : ImportYamlCommandHelp,ConversionError,Microsoft.PowerShell.PlatyPS.ImportYamlMetadataCommand
InvocationInfo        :
    MyCommand        : Import-YamlCommandHelp
    ScriptLineNumber : 1
    OffsetInLine     : 6
    HistoryId        : 47
    Line             : $y = Import-YamlCommandHelp .\DnsClient\Resolve-DnsName.yml
    Statement        : Import-YamlCommandHelp .\DnsClient\Resolve-DnsName.yml
    PositionMessage  : At line:1 char:6
                       + $y = Import-YamlCommandHelp .\DnsClient\Resolve-DnsName.yml
                       +      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    InvocationName   : Import-YamlCommandHelp
    CommandOrigin    : Internal
ScriptStackTrace      : at <ScriptBlock>, <No file>: line 1
PipelineIterationInfo :
      0
      1

Environment data

Latest private build for preview5.

Visuals

No response

Metadata

Metadata

Labels

BlockedTag - blocked on something external to this repoResolution-FixedThe issue is fixed.

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions