-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Closed
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.The issue is fixed.WG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module
Description
When running the ConvertFrom-Markdown command from within a new runspace, the command throws a null reference exception.
Steps to reproduce
$pool = [runspacefactory]::CreateRunspacePool(1, 2, $Host)
$pool.Open()
$ps = [powershell]::Create()
$ps.RunspacePool = $pool
$ps.AddScript({
try {
'# test' | ConvertFrom-Markdown | Out-Default
}
catch {
$_ | Out-Default
}
}) | Out-Null
$ps.Invoke()
$ps.Dispose()Expected behavior
The command should return a MarkdownInfo object
Actual behavior
The command throws a null reference exception:
ConvertFrom-Markdown : Object reference not set to an instance of an object.
At line:3 char:21
+ '# test' | ConvertFrom-Markdown | Out-Default
+ ~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [ConvertFrom-Markdown], NullReferenceException
+ FullyQualifiedErrorId : System.NullReferenceException,Microsoft.PowerShell.Commands.ConvertFromMarkdownCommand
Environment data
Name Value
---- -----
PSVersion 6.2.0
PSEdition Core
GitCommitId 6.2.0
OS Linux 4.4.0-43-Microsoft #1-Microsoft Wed Dec 31 14:42:53 PST 2014
Platform Unix
PSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}
PSRemotingProtocolVersion 2.3
SerializationVersion 1.1.0.1
WSManStackVersion 3.0
(note: the same happens on Windows, too)
Notes
Looking into the code, it seems to be caused by the following line:
PowerShell/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ConvertFromMarkdownCommand.cs
Line 69 in 2174dd8
| _mdOption = this.CommandInfo.Module.SessionState.PSVariable.GetValue("PSMarkdownOptionInfo", new PSMarkdownOptionInfo()) as PSMarkdownOptionInfo; |
The this.CommandInfo.Module is null when running within a new runspace. The line appears to create a default PSMarkdownOptionInfo object if the session variable is null - so if the module is null maybe create a default PSMarkdownOptionInfo?
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
Issue-BugIssue has been identified as a bug in the productIssue has been identified as a bug in the productResolution-FixedThe issue is fixed.The issue is fixed.WG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module