Title: Non-predefined preference variables aren't type-/value-constrained. · Issue #3644 · PowerShell/PowerShell · GitHub
Open Graph Title: Non-predefined preference variables aren't type-/value-constrained. · Issue #3644 · PowerShell/PowerShell
X Title: Non-predefined preference variables aren't type-/value-constrained. · Issue #3644 · PowerShell/PowerShell
Description: Related: #3483 Preference variable $ErrorView, despite only supporting 2 values - NormalView and CategorizedView - is defined as a [string] and therefore quietly accepts any value (and falls back to NormalView). [This has been fixed] It ...
Open Graph Description: Related: #3483 Preference variable $ErrorView, despite only supporting 2 values - NormalView and CategorizedView - is defined as a [string] and therefore quietly accepts any value (and falls back t...
X Description: Related: #3483 Preference variable $ErrorView, despite only supporting 2 values - NormalView and CategorizedView - is defined as a [string] and therefore quietly accepts any value (and falls back t...
Opengraph URL: https://github.com/PowerShell/PowerShell/issues/3644
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"Non-predefined preference variables aren't type-/value-constrained.","articleBody":"\u003csup>Related: #3483\u003c/sup>\r\n\r\n~Preference variable `$ErrorView`, despite only supporting 2 values - `NormalView` and `CategorizedView` - is defined as a `[string]` and therefore quietly accepts any value (and falls back to `NormalView`).~ [This has been fixed]\r\n\r\nIt should probably be an enumeration type, as similar preference variables are (e.g., `$ErrorActionPreference -is [enum]` returns `$true`)\r\n\r\nSimilarly, the fact that some preference variables aren't _predefined_ altogether allows their creation with inappropriate types. \r\n\r\nNote that this problem exists separately from the fact that [creating preference variables in _child_ scopes never enforces their intended types](https://github.com/PowerShell/PowerShell/issues/3483), even if they're appropriately type-constrained in the global scope.\r\n\r\nSteps to reproduce\r\n------------------\r\n\r\n```powershell\r\n$LogCommandHealthEvent = 'I should be a Boolean'\r\n```\r\n\r\nExpected behavior\r\n-----------------\r\n\r\n(Statement-terminating) errors complaining about the inappropriate values.\r\n\r\nActual behavior\r\n---------------\r\n\r\nThe invalid values are quietly accepted.\r\n\r\nCurrently, the following preference variables aren't predefined:\r\n\r\n* `[bool]`: `LogCommandHealthEvent LogCommandLifecycleEvent LogEngineHealthEvent LogEngineLifecycleEvent LogProviderLifecycleEvent LogProviderHealthEvent`\r\n\r\n* `[int]`: `MaximumAliasCount, MaximumDriveCount, MaximumErrorCount, MaximumFunctionCount, MaximumVariableCount` - these _are_ predefined in Windows PowerShell v5.1, however.\r\n\r\n* enum `[PSModuleAutoLoadingPreference]`: `PSModuleAutoLoadingPreference`\r\n\r\n* `[string]`: `OFS`, but given that it is conceptually `[string]` and that any value can be converted to a string, that is less of an issue.\r\n\r\n* Others?\r\n\r\nEnvironment data\r\n----------------\r\n\r\n```powershell\r\nPowerShell Core v6.0.0-alpha (v6.0.0-alpha.18) on Darwin Kernel Version 16.5.0: Fri Mar 3 16:52:33 PST 2017; root:xnu-3789.51.2~3/RELEASE_X86_64\r\n```\r\n","author":{"url":"https://github.com/mklement0","@type":"Person","name":"mklement0"},"datePublished":"2017-04-25T18:07:26Z","url":"https://github.com/PowerShell/PowerShell/issues/3644"}
| 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:c1d815a0-e128-a245-e826-2951a248f512 |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | 9F44:3A7D16:25BAA4A:34D6F6D:6AFD4E61 |
| html-safe-nonce | 1c736b1234e942bd6e17b481b79e29ff63d394c945d193b40c1258ae515f3877 |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiI5RjQ0OjNBN0QxNjoyNUJBQTRBOjM0RDZGNkQ6NkFGRDRFNjEiLCJ2aXNpdG9yX2lkIjoiODgwMDE2Mjc0MTczOTE0Njg1MCIsInJlZ2lvbl9lZGdlIjoiaWFkIiwicmVnaW9uX3JlbmRlciI6ImlhZCJ9 |
| visitor-hmac | c7c949b452a6497536b7aea88506a0b27c16fc88e2d4da0fe3d70a070f1bb339 |
| hovercard-subject-tag | issue:224225176 |
| 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/3644/issue_layout |
| twitter:image | https://opengraph.githubassets.com/1b04ae66647e69e143b78c6788e812d4fa4cb84b1824ac7cc5a9556ea0f484a0/PowerShell/PowerShell/issues/3644 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/1b04ae66647e69e143b78c6788e812d4fa4cb84b1824ac7cc5a9556ea0f484a0/PowerShell/PowerShell/issues/3644 |
| og:image:alt | Related: #3483 Preference variable $ErrorView, despite only supporting 2 values - NormalView and CategorizedView - is defined as a [string] and therefore quietly accepts any value (and falls back t... |
| 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 | 66653c2e55a6fff2930be1bdf07ee4f8aa137e3956d056c822563be6f878755e |
| 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 | b6f01f7cb9f35f8c09949773241a3d49dd04b340 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
| react-app-name | issues |
Links:
Viewport: width=device-width