platyPS icon indicating copy to clipboard operation
platyPS copied to clipboard

V2 Invalid output generated with v2 - Exception calling "NodeModelToMamlModel" with "1" argument(s)

Open DEberhardt opened this issue 4 years ago • 4 comments

Steps to reproduce

Install-Module PlatyPs #Installing v1
Install-Module PlatyPs -AllowPrerelease #adding v2

Expected behavior

No errors when running New-Markdownhelp - running it with v0.14.1 results in no issues

Actual behavior

Exception calling "NodeModelToMamlModel" with "1" argument(s): "D:\Code\Personal\TeamsFunctions\docs\Test-TeamsUserVoiceConfig.md:82:(550) '```yaml
Type: String
Parameter Sets: (All)
Alia...'
 Invalid yaml: unknown key DontShow"
At C:\Users\David\Documents\WindowsPowerShell\Modules\platyPS\0.14.1\platyPS.psm1:1574 char:9
+         $maml = $t.NodeModelToMamlModel($model)
+         ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : NotSpecified: (:) [], MethodInvocationException
    + FullyQualifiedErrorId : HelpSchemaException

Get-Command : Cannot validate argument on parameter 'Name'. The argument is null or empty. Provide an argument that is not null or empty, and then try the command again.       
At C:\Users\David\Documents\WindowsPowerShell\Modules\platyPS\0.14.1\platyPS.psm1:438 char:36
+             $command = Get-Command $name -ErrorAction SilentlyContinu ...
+                                    ~~~~~
    + CategoryInfo          : InvalidData: (:) [Get-Command], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,Microsoft.PowerShell.Commands.GetCommandCommand

GetMamlObject : Cannot bind argument to parameter 'Cmdlet' because it is an empty string.
At C:\Users\David\Documents\WindowsPowerShell\Modules\platyPS\0.14.1\platyPS.psm1:460 char:72
+ ... flectionModel = GetMamlObject -Session $Session -Cmdlet $name -UseFul ...
+                                                             ~~~~~
    + CategoryInfo          : InvalidData: (:) [GetMamlObject], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorEmptyStringNotAllowed,GetMamlObject

ConvertMamlModelToMarkdown : Cannot validate argument on parameter 'mamlCommand'. The argument is null or empty. Provide an argument that is not null or empty, and then try    
the command again.
At C:\Users\David\Documents\WindowsPowerShell\Modules\platyPS\0.14.1\platyPS.psm1:471 char:59
+ ...       $md = ConvertMamlModelToMarkdown -mamlCommand $newModel -metada ...
+                                                         ~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [ConvertMamlModelToMarkdown], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationError,ConvertMamlModelToMarkdown

New Schema is applied, though all output is mismatched - all .md files are containing wrong information. They are generated with the following commands:

function Update-DocsAndPester {
  #Simple Function to update MarkdownHelp and running pester

  $Directory = 'D:\Code\Personal\TeamsFunctions\'
  Set-Location $Directory
  Switch-TeamsFunctions 1

  $created = New-MarkdownHelp -Module TeamsFunctions -OutputFolder "$Directory`docs" -Force -AlphabeticParamsOrder:$false
  Write-Verbose -Message "MarkdownHelp created: $($created.Count) files created" -Verbose

  $Updated = Update-MarkdownHelp -Path "$Directory`docs" -Force -UpdateInputOutput -AlphabeticParamsOrder:$false
  Write-Verbose -Message "MarkdownHelp updated: $($Updated.Count) files changed" -Verbose

  $ExternalHelp = New-ExternalHelp -Path "$Directory`docs" -OutputPath "$Directory`docs" -Force
  Write-Verbose -Message "ExternalHelp re-created: $($ExternalHelp.Count) files replaced" -Verbose

  Set-Location $Directory

  Invoke-Pester
}
Set-Alias -Name docu -Value Update-DocsAndPester

reverting to v0.14.1 for now

Environment data

PowerShell Version Table

Name                           Value
----                           -----
PSVersion                      5.1.19041.906
PSEdition                      Desktop
PSCompatibleVersions           {1.0, 2.0, 3.0, 4.0...}
BuildVersion                   10.0.19041.906
CLRVersion                     4.0.30319.42000
WSManStackVersion              3.0
PSRemotingProtocolVersion      2.3
SerializationVersion           1.1.0.1

Installed NET Frameworks



PSChildName                      Version        Release
-----------                      -------        -------
v2.0.50727                       2.0.50727.4927
v3.0                             3.0.30729.4926
Windows Communication Foundation 3.0.4506.4926
Windows Presentation Foundation  3.0.6920.4902
v3.5                             3.5.30729.4926
Client                           4.8.04084      528372
Full                             4.8.04084      528372
Client                           4.0.0.0

DEberhardt avatar May 22 '21 16:05 DEberhardt

Hi @DEberhardt, thank you for reporting this issue. To further investigate this problem, could you provide your source markdown with yaml block for which you are receiving this error. An additional question, I notice the error Invalid yaml: unknown key DontShow - Do you know how DontShow got into your yaml block? Have you tried running New-MarkdownHelp with the -ExcludeDontShow parameter?

theJasonHelmick avatar Jun 08 '21 17:06 theJasonHelmick

THE Jason Helmick answers an unworthy post of mine?😮 But... I am unworthy! I think I need a lie-down...

First of all, Thank you for your PowerShell 3.0 video course with THE Jeffrey Snover! - you kickstarted my scripting capabilities by making it fun and enjoyable to code! Now I not only "don't fear the shell", I also don't fear the VsCode! Thank you!

To answer your question, all of my .MD files are here

Branching off here, PlatyPsV2Test, I have the updated version (v0.14.1 to v2.0.0-preview1)

In Branch PlatyPsv2Recreated I have executed Order 66 on the docs and recreated them all. Running the same commands with my Update-DocsAndPester Function, the first time round, no errors, the second time, also no errors?

I can only conclude that v0.14.1 does something that v2 cannot update? i.E. v2.0.0-preview is sound, provided you don't update from previous versions?

Taking out one of the error-messages, I can't find -DontShow in the Yaml blocks...

### -UserPrincipalName
This is the UserID (UPN)

```yaml
Type: String
Parameter Sets: (All)
Aliases: ObjectId, Identity

Required: True
Position: 1
Default value: None
Accept pipeline input: True (ByValue)
Accept wildcard characters: False
\```

The block looks the same prior and post update...

PS: Running New-MarkdownHelp with -ExcludeDontShow results in an error:

New-MarkdownHelp : A parameter cannot be found that matches parameter name 'ExcludeDontShow'.
At C:\Users\David\Documents\WindowsPowerShell\Modules\TeamsFunctionsModuleSwitcherHome.psm1:357 char:123
+ ... Directory`docs" -Force -AlphabeticParamsOrder:$false -ExcludeDontShow
+                                                          ~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidArgument: (:) [New-MarkdownHelp], ParameterBindingException
    + FullyQualifiedErrorId : NamedParameterNotFound,Microsoft.PowerShell.PlatyPS.NewMarkdownHelpCommand

Running Update-MarkdownHelp with it results in v0.14.1 being imported (as it is not available in v2.0.0-preview^^)

DEberhardt avatar Jun 10 '21 21:06 DEberhardt

I am also having this problem. All my markdown is generated with New-MarkdownHelp within a build function I use universally on internal modules. Is this -ExcludeDontShow param new in 0.14.1? Part of a schema change or something? It's broken my build script, but I'm going to try adding this parameter to my build function and see what happens.

darksidemilk avatar Jun 17 '21 15:06 darksidemilk

what strikes me as odd is that I run first NEW (importing v2), then UPDATE-MarkdownHelp (v0.14.1) The first time around I get all the errors, if I run it again, it works as intended. I am not sure whether the second time it loads New-Markdownhelp from 0.14.1?

DEberhardt avatar Jul 03 '21 12:07 DEberhardt

Microsoft.PowerShell.PlatyPS is a complete rewrite. This issue no longer applies.

sdwheeler avatar May 24 '24 15:05 sdwheeler