Skip to content

Standardize ErrorCategory and ErrorId for parameter conflict validation errors #26570

@yotsuda

Description

@yotsuda

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:

  1. Can a cmdlet parameter be considered an "argument"? If yes, InvalidArgument would be semantically appropriate. If not, a new InvalidParameter category might be more accurate, though this would require PowerShell Committee approval as a public API change.
  2. Should ErrorId naming also be standardized? Currently there are two patterns: CannotSpecify... and FormatCannotSpecify....

Related: #26472 (discussion origin)

Proposed technical implementation details (optional)

Options include:

  • Option A: Standardize on InvalidArgument and FormatCannotSpecify... prefix (align with Format-* cmdlets)
  • Option B: Standardize on InvalidData and CannotSpecify... prefix (align with Csv/Select-String cmdlets)
  • Option C: Propose new InvalidParameter category with unified CannotSpecify... prefix (requires Committee approval, longer timeline)

Metadata

Metadata

Assignees

No one assigned

    Labels

    Issue-Enhancementthe issue is more of a feature request than a bugNeeds-TriageThe issue is new and needs to be triaged by a work group.WG-Cmdletsgeneral cmdlet issues

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions