microsoft / winget-cli

WinGet is the Windows Package Manager. This project includes a CLI (Command Line Interface), PowerShell modules, and a COM (Component Object Model) API (Application Programming Interface).
https://learn.microsoft.com/windows/package-manager/
MIT License
22.96k stars 1.43k forks source link

Better validation output messages for PackageIdentifier schema issues #4712

Open jbne opened 1 month ago

jbne commented 1 month ago

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:

mdanish-kh commented 1 month ago

[Policy] Area-Output