microsoft / microsoft/winget-cli
Better validation output messages for PackageIdentifier schema issues
Nobody has claimed this yet.
- Dominant language
- C++
- Stars
- 26.4k
- Forks
- 1.8k
- Avg merge
- 1d 11h
- Merged PRs (30d)
- 15
Description
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"
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the winget validate command and the PackageIdentifier schema-validation path shown in the issue. Determine whether validation can expose the failing pattern or needs PackageIdentifier-specific diagnostics; done means invalid identifiers produce actionable messages for the described malformed, invalid-character, overlong, and excessive-part examples, with validation coverage added.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- cpp
- Domain
- cli
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 30/100