microsoft / microsoft/winget-cli

winget configure export generates invalid resource names

Open
#5,675 5 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

Command-Configure Issue-Bug
Dominant language
C++
Stars
26.4k
Forks
1.8k
Avg merge
1d 11h
Merged PRs (30d)
15

Description

Relevant area(s)

WinGet CLI

Relevant command(s)

winget configure

Brief description of your issue

The resource names generated by winget configure export are invalid, given the specified JSON schema.

Image

When you create a .winget file using the command winget configure export --all -o test.winget, for example, the $schema property is specified as

https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/08/config/document.json

If you look into the schema, the resource property is defined at

https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/08/config/document.resource.json

Which in turn, defines the name property at

https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/08/definitions/instanceName.json

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/2023/08/definitions/instanceName.json",
"title": "Instance name",
"description": "The short, human-readable name for a DSC Resource instance. Must be unique within a DSC Configuration document. Must be a non-empty string containing only letters, numbers, and spaces.",
"type": "string",
"pattern": "^[a-zA-Z0-9 ]+$",
"minLength": 1
}

But none of the resource names generated by winget configure export comply with the specified schema (which expects a resource name containing only letters, numbers, and spaces), thus being invalid.

Example of generated resource names:

  • Microsoft.WinGet/Package_ceux42u2
  • Microsoft.WinGet/AdminSettings-0
  • winget_Notepad++.Notepad++
  • winget_Microsoft.Office

Even if you use the (I assume) newer version of the schema

https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3.1.0/config/document.json

The definition is still exactly the same, and the resource names would still be invalid

https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3.1.0/definitions/instanceName.json

{
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://raw.githubusercontent.com/PowerShell/DSC/main/schemas/v3.1.0/definitions/instanceName.json",
"title": "Instance name",
"description": "The short, human-readable name for a DSC resource instance. Must be unique within a DSC Configuration document. Must be a non-empty string containing only letters, numbers, and spaces.",
"type": "string",
"pattern": "^[a-zA-Z0-9 ]+$",
"minLength": 1
}

Steps to reproduce

winget configure export --all -o test.winget

Expected behavior

Generated resource names should be valid, given the specified JSON schema validation rules.

Actual behavior

The generated resource names are invalid per the specified JSON schema.

Environment
Windows Package Manager v1.11.430
Copyright (c) Microsoft Corporation. All rights reserved.

Windows: Windows.Desktop v10.0.26100.4946
System Architecture: X64
Package: Microsoft.DesktopAppInstaller v1.26.430.0

Winget Directories
-----------------------------------------------------------------------------------------------------------------------
Logs                               %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\Diag…
User Settings                      %LOCALAPPDATA%\Packages\Microsoft.DesktopAppInstaller_8wekyb3d8bbwe\LocalState\sett…
Portable Links Directory (User)    %LOCALAPPDATA%\Microsoft\WinGet\Links
Portable Links Directory (Machine) C:\Program Files\WinGet\Links
Portable Package Root (User)       %LOCALAPPDATA%\Microsoft\WinGet\Packages
Portable Package Root              C:\Program Files\WinGet\Packages
Portable Package Root (x86)        C:\Program Files (x86)\WinGet\Packages
Installer Downloads                %USERPROFILE%\Downloads
Configuration Modules              %LOCALAPPDATA%\Microsoft\WinGet\Configuration\Modules

Links
---------------------------------------------------------------------------
Privacy Statement   https://aka.ms/winget-privacy
License Agreement   https://aka.ms/winget-license
Third Party Notices https://aka.ms/winget-3rdPartyNotice
Homepage            https://aka.ms/winget
Windows Store Terms https://www.microsoft.com/en-us/storedocs/terms-of-sale

Admin Setting                             State
--------------------------------------------------
LocalManifestFiles                        Disabled
BypassCertificatePinningForMicrosoftStore Disabled
InstallerHashOverride                     Disabled
LocalArchiveMalwareScanOverride           Disabled
ProxyCommandLineOptions                   Disabled
DefaultProxy                              Disabled

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the winget configure export --all -o test.winget entry point and validate its generated resource names against the referenced DSC instanceName schema. Trace how names such as Microsoft.WinGet/Package_ceux42u2 are produced; done means exported .winget files pass the schema's letters, numbers, and spaces rule.

Written by the indexing model from the issue text.

Assessment

Tech stack
cpp
Domain
cli
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
42/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.