Title: Get-Error unexpectedly modifies the ETS type names of the ErrorRecord instances it processes in place · Issue #11122 · PowerShell/PowerShell · GitHub
Open Graph Title: Get-Error unexpectedly modifies the ETS type names of the ErrorRecord instances it processes in place · Issue #11122 · PowerShell/PowerShell
X Title: Get-Error unexpectedly modifies the ETS type names of the ErrorRecord instances it processes in place · Issue #11122 · PowerShell/PowerShell
Description: The handy new Get-Error cmdlet implements its pretty-printing by replacing the System.Management.Automation.ErrorRecord type name in the ETS type-name array with PSExtendedError. Unfortunately, it does this on the originals in the $Error...
Open Graph Description: The handy new Get-Error cmdlet implements its pretty-printing by replacing the System.Management.Automation.ErrorRecord type name in the ETS type-name array with PSExtendedError. Unfortunately, it ...
X Description: The handy new Get-Error cmdlet implements its pretty-printing by replacing the System.Management.Automation.ErrorRecord type name in the ETS type-name array with PSExtendedError. Unfortunately, it ...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/11122
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Get-Error unexpectedly modifies the ETS type names of the ErrorRecord instances it processes in place","articleBody":"The handy new `Get-Error` cmdlet implements its pretty-printing by replacing the `System.Management.Automation.ErrorRecord` type name in the ETS type-name array with `PSExtendedError`.\r\n\r\nUnfortunately, it does this on the _originals_ in the `$Error` collection, resulting in inadvertent modification that makes these instances print differently with implicit output (e.g., `$Error[0]`) afterwards.\r\n\r\n# Steps to reproduce\r\n\r\n```powershell\r\n# Provoke a an error.\r\ntry { 1 / 0 } catch {}\r\n\r\n$Error[0].pstypenames | Should -Be System.Management.Automation.ErrorRecord, System.Object\r\n\r\n# Run Get-Error, which accidentally modifies .pstypenames of the most recent error.\r\n$null = Get-Error \r\n\r\n# Repeating the test shows the modified .pstypenames\r\n$Error[0].pstypenames | Should -Be System.Management.Automation.ErrorRecord, System.Object\r\n```\r\n\r\n# Expected behavior\r\n\r\nBoth tests should succeed.\r\n\r\n# Actual behavior\r\n\r\nThe 2nd test fails:\r\n\r\n```none\r\n Expected @('System.Management.Automation.ErrorRecord', 'System.Object'), but got @('PSExtendedError', 'System.Object').\r\n```\r\n\r\nThat is, `$Error[0]`'s `.pstypename` property was accidentally modified.\r\n\r\n# Environment data\r\n\r\n```none\r\nPowerShell Core 7.0.0-preview.5\r\n```\r\n","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2019-11-19T18:45:55Z","url":"https://github.com/PowerShell/PowerShell/issues/11122"}
| 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:6f01450d-28f9-ffcb-7937-69fbadafbdde |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | B62E:180C65:571F5:75D34:6AFD4882 |
| html-safe-nonce | 5bcf1c301e75fd57bdad921cf757508dbe35731ed311845332699af12ce8da93 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJCNjJFOjE4MEM2NTo1NzFGNTo3NUQzNDo2QUZENDg4MiIsInZpc2l0b3JfaWQiOiIyNDI0NTY4ODM5MjE2NjQ2Mjc0IiwicmVnaW9uX2VkZ2UiOiJpYWQiLCJyZWdpb25fcmVuZGVyIjoiaWFkIn0= |
| visitor-hmac | 144ecad880d21b63b1c164d5a9ae16f27ddfc89bec6a856e9fa167524e9ad3db |
| hovercard-subject-tag | issue:525194078 |
| 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/11122/issue_layout |
| twitter:image | https://opengraph.githubassets.com/7b9278a80a989a8ff07485b1af0290f9f7bde30ebce731284094094131ca5deb/PowerShell/PowerShell/issues/11122 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/7b9278a80a989a8ff07485b1af0290f9f7bde30ebce731284094094131ca5deb/PowerShell/PowerShell/issues/11122 |
| og:image:alt | The handy new Get-Error cmdlet implements its pretty-printing by replacing the System.Management.Automation.ErrorRecord type name in the ETS type-name array with PSExtendedError. Unfortunately, it ... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | mklement0 |
| hostname | github.com |
| expected-hostname | github.com |
| None | bdbacc25b921224ff0befcb9e629560a1255be51aec9991d6e3f95b5e9151474 |
| 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 | 556dd37bb0aceffb25724e151b5d858b3265b40b |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width