-
Notifications
You must be signed in to change notification settings - Fork 8.1k
Open
Labels
Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugNeeds-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.WG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues
Description
Summary of the new feature / enhancement
Parameter conflict validation errors (e.g., "Cannot specify both -X and -Y") currently use inconsistent ErrorCategory values across cmdlets:
| Cmdlet | Conflicting Parameters | ErrorId | ErrorCategory |
|---|---|---|---|
| Export-Csv / ConvertTo-Csv | -QuoteFields / -UseQuotes | CannotSpecifyQuoteFieldsAndUseQuotes | InvalidData |
| Export-Csv / ConvertTo-Csv | -IncludeTypeInformation / -NoTypeInformation | CannotSpecifyIncludeTypeInformationAndNoTypeInformation | InvalidData |
| Export-Csv | -Path / -LiteralPath | CannotSpecifyPathAndLiteralPath | InvalidData |
| Export-Csv | -Append / -NoHeader | CannotSpecifyBothAppendAndNoHeader | InvalidData |
| Select-String | -Culture (requires -SimpleMatch) | CannotSpecifyCultureWithoutSimpleMatch | InvalidData |
| Format-Table / List / Custom | -View / -Property | FormatCannotSpecifyViewAndProperty | InvalidArgument |
| Format-Wide | -AutoSize / -Column | FormatCannotSpecifyAutosizeAndColumns | InvalidArgument |
Note: Select-String's error is a dependency requirement rather than a mutual exclusion, but it shares the same inconsistency issue.
Standardizing ErrorCategory and ErrorId naming for parameter validation errors would improve consistency and make error handling more predictable for users and scripts.
Key questions for discussion:
- Can a cmdlet parameter be considered an "argument"? If yes,
InvalidArgumentwould be semantically appropriate. If not, a newInvalidParametercategory might be more accurate, though this would require PowerShell Committee approval as a public API change. - Should ErrorId naming also be standardized? Currently there are two patterns:
CannotSpecify...andFormatCannotSpecify....
Related: #26472 (discussion origin)
Proposed technical implementation details (optional)
Options include:
- Option A: Standardize on
InvalidArgumentandFormatCannotSpecify...prefix (align with Format-* cmdlets) - Option B: Standardize on
InvalidDataandCannotSpecify...prefix (align with Csv/Select-String cmdlets) - Option C: Propose new
InvalidParametercategory with unifiedCannotSpecify...prefix (requires Committee approval, longer timeline)
mklement0
Metadata
Metadata
Assignees
Labels
Issue-Enhancementthe issue is more of a feature request than a bugthe issue is more of a feature request than a bugNeeds-TriageThe issue is new and needs to be triaged by a work group.The issue is new and needs to be triaged by a work group.WG-Cmdletsgeneral cmdlet issuesgeneral cmdlet issues