Skip to content

Better validation output messages for PackageIdentifier schema issues #4712

@jbne

Description

@jbne

Description of the new feature / enhancement

When I use winget validate with a PackageIdentifier that does not meet the schema, the output looks like this:

> winget validate .\RemoteToolsForVisualStudio2022\Latest
Manifest validation failed.
Manifest Error: Schema Error. [Schema validation failed.
Error context: <root>[PackageIdentifier] Description: Failed to match regex specified by 'pattern' constraint.
Error context: <root> Description: Failed to validate against schema associated with property name 'PackageIdentifier'.
] File: Microsoft.RemoteToolsForVisualStudio2022.installer.yaml
Manifest Error: Schema Error. [Schema validation failed.
Error context: <root>[PackageIdentifier] Description: Failed to match regex specified by 'pattern' constraint.
Error context: <root> Description: Failed to validate against schema associated with property name 'PackageIdentifier'.
] File: Microsoft.RemoteToolsForVisualStudio2022.locale.en-US.yaml
Manifest Error: Schema Error. [Schema validation failed.
Error context: <root>[PackageIdentifier] Description: Failed to match regex specified by 'pattern' constraint.
Error context: <root> Description: Failed to validate against schema associated with property name 'PackageIdentifier'.
] File: Microsoft.RemoteToolsForVisualStudio2022.yaml

That doesn't really give any indication on what the issue is with the PackageIdentifier to the user - they have to manually go to the correct manifest schema and see what 'pattern' corresponds to, as well as having to interpret the long regex string to determine which part did not match it. It would be nice if either the regex pattern was displayed, or a specific error was given that indicates what is exactly wrong with the PackageIdentifier.

Proposed technical implementation details

Either one of these would be better:

  • Display the regex pattern in the error message
  • Detect which part failed the regex pattern and give an appropriate error message to the user. Some examples:
    • "ThisIsAPackageIdentifier" --> "PackageIdentifier must be of the form publisher.packagename"
    • "Publisher.Package?" --> "Invalid character '?' found in PackageIdentifier"
    • "123456789012345678901234567890123.Package" --> "Publisher name must be between 1 and 32 characters."
    • "1.2.3.4.5.6.7.8.9" --> "Too many parts, PackageIdentifier must be of the form publisher.packagename"

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-OutputIssue related to CLI outputCommand-ValidateIssue related to WinGet ValidateIssue-FeatureThis is a feature request for the Windows Package Manager client.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions