-
Notifications
You must be signed in to change notification settings - Fork 8.2k
Get-TypeData with a non-wildcard type name that matches no loaded type data quietly returns nothing #7521
Copy link
Copy link
Closed
Labels
Breaking-Changebreaking change that may affect usersbreaking change that may affect usersCommittee-ReviewedPS-Committee has reviewed this and made a decisionPS-Committee has reviewed this and made a decisionIssue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module
Metadata
Metadata
Assignees
Labels
Breaking-Changebreaking change that may affect usersbreaking change that may affect usersCommittee-ReviewedPS-Committee has reviewed this and made a decisionPS-Committee has reviewed this and made a decisionIssue-Discussionthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifthe issue may not have a clear classification yet. The issue may generate an RFC or may be reclassifResolution-No ActivityIssue has had no activity for 6 months or moreIssue has had no activity for 6 months or moreUp-for-GrabsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsUp-for-grabs issues are not high priorities, and may be opportunities for external contributorsWG-Cmdlets-Utilitycmdlets in the Microsoft.PowerShell.Utility modulecmdlets in the Microsoft.PowerShell.Utility module
Follow-up from #7434 and related to #7498.
Note that this is a longstanding, albeit undocumented, behavior, and changing it now may break existing scripts, so there are two possible resolutions:
Conclude that changing this would break too many scripts and therefore make do with documenting the surprising / inconsistent behavior.
Conclude that this is a Bucket 3 change and make the change nonetheless.
The current behavior - quietly returning nothing and signaling success in
$?- deviates from the typical behavior of asking for specific entities with literal names, e.g.,Get-Item NoSuch.Steps to reproduce
Ask for nonexistent type data with a type name that doesn't include wildcard characters:
Get-TypeData NoSuchTypeExpected behavior
A non-terminating error indicating that no such type data is loaded into the current session.
$?should indicate$FalseThe error message should be similar to the one for
Get-FormatData(which is suboptimal as of this writing), which, modeled on my suggestion here, could be something like:Actual behavior
Nothing (
[System.Management.Automation.Internal.AutomationNull]::Value) is output, and$?reflects$True.While this behavior may make sense for wildcard-based arguments, it doesn't for literal ones.
Compare this to the behavior of cmdlets such as
Get-Item,Get-ChildItem,Get-Content, ..., which all fail if a given non-wildcard path doesn't identify an existing file.Environment data