Title: ConvertFrom-Markdown throws Null Exception when run inside Runspace · Issue #9390 · PowerShell/PowerShell · GitHub
Open Graph Title: ConvertFrom-Markdown throws Null Exception when run inside Runspace · Issue #9390 · PowerShell/PowerShell
X Title: ConvertFrom-Markdown throws Null Exception when run inside Runspace · Issue #9390 · PowerShell/PowerShell
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]::Creat...
Open Graph 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...
X 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...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/9390
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"ConvertFrom-Markdown throws Null Exception when run inside Runspace","articleBody":"When running the `ConvertFrom-Markdown` command from within a new runspace, the command throws a null reference exception.\r\n\r\n# Steps to reproduce\r\n\r\n```powershell\r\n$pool = [runspacefactory]::CreateRunspacePool(1, 2, $Host)\r\n$pool.Open()\r\n\r\n$ps = [powershell]::Create()\r\n$ps.RunspacePool = $pool\r\n$ps.AddScript({\r\n try {\r\n '# test' | ConvertFrom-Markdown | Out-Default\r\n }\r\n catch {\r\n $_ | Out-Default\r\n }\r\n}) | Out-Null\r\n\r\n$ps.Invoke()\r\n$ps.Dispose()\r\n```\r\n\r\n# Expected behavior\r\n\r\n```none\r\nThe command should return a MarkdownInfo object\r\n```\r\n\r\n# Actual behavior\r\n\r\n```none\r\nThe command throws a null reference exception:\r\n\r\nConvertFrom-Markdown : Object reference not set to an instance of an object.\r\nAt line:3 char:21\r\n+ '# test' | ConvertFrom-Markdown | Out-Default\r\n+ ~~~~~~~~~~~~~~~~~~~~\r\n+ CategoryInfo : NotSpecified: (:) [ConvertFrom-Markdown], NullReferenceException\r\n+ FullyQualifiedErrorId : System.NullReferenceException,Microsoft.PowerShell.Commands.ConvertFromMarkdownCommand\r\n```\r\n\r\n# Environment data\r\n\r\n```none\r\nName Value\r\n---- -----\r\nPSVersion 6.2.0\r\nPSEdition Core\r\nGitCommitId 6.2.0\r\nOS Linux 4.4.0-43-Microsoft #1-Microsoft Wed Dec 31 14:42:53 PST 2014\r\nPlatform Unix\r\nPSCompatibleVersions {1.0, 2.0, 3.0, 4.0…}\r\nPSRemotingProtocolVersion 2.3\r\nSerializationVersion 1.1.0.1\r\nWSManStackVersion 3.0\r\n```\r\n\r\n(note: the same happens on Windows, too)\r\n\r\n# Notes\r\n\r\nLooking into the code, it seems to be caused by the following line: https://github.com/PowerShell/PowerShell/blob/2174dd81a4e624932feee4457ca376203b14c8ac/src/Microsoft.PowerShell.Commands.Utility/commands/utility/ConvertFromMarkdownCommand.cs#L69\r\n\r\nThe `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`?","author":{"url":"https://github.com/Badgerati","@type":"Person","name":"Badgerati"},"datePublished":"2019-04-17T22:01:28Z","url":"https://github.com/PowerShell/PowerShell/issues/9390"}
| 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:2d73c77c-9668-f8da-b0f3-1a522a0cfe20 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 8A0E:2DE6C5:1739F0:20A831:6AFD6E69 |
| html-safe-nonce | d3ac61c957c5137fcadf4d8d32b33098cf48e016e5812b1deb28dc938f4e0888 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI4QTBFOjJERTZDNToxNzM5RjA6MjBBODMxOjZBRkQ2RTY5IiwidmlzaXRvcl9pZCI6IjQ3NTUzNjUyNjkxMTc2OTM1NDUiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | b531c7f83198e09a32496903f3f1dceca028d58d27a1865ae0deb4a913f4544e |
| hovercard-subject-tag | issue:434505153 |
| 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/PowerShell/9390/issue_layout |
| twitter:image | https://opengraph.githubassets.com/ffd0928afee4c80a2d0cd45d9f825efe9afd81198df732ca530a9affb3588f6b/PowerShell/PowerShell/issues/9390 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/ffd0928afee4c80a2d0cd45d9f825efe9afd81198df732ca530a9affb3588f6b/PowerShell/PowerShell/issues/9390 |
| og:image:alt | 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... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | Badgerati |
| hostname | github.com |
| expected-hostname | github.com |
| None | 9985ca2e21b59673104d4d830d4afeb946c67f248f273ab2e824c31c8db46e4a |
| turbo-cache-control | no-preview |
| go-import | github.com/PowerShell/PowerShell git https://github.com/PowerShell/PowerShell.git |
| octolytics-dimension-user_id | 11524380 |
| octolytics-dimension-user_login | PowerShell |
| octolytics-dimension-repository_id | 49609581 |
| octolytics-dimension-repository_nwo | PowerShell/PowerShell |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 49609581 |
| octolytics-dimension-repository_network_root_nwo | PowerShell/PowerShell |
| 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 | 0db9e8d463c3f4540570e6ad3c501a06db9dc02a |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width