Skip to content

Source priority#6029

Open
JohnMcPMS wants to merge 18 commits intomicrosoft:masterfrom
JohnMcPMS:src-pri
Open

Source priority#6029
JohnMcPMS wants to merge 18 commits intomicrosoft:masterfrom
JohnMcPMS:src-pri

Conversation

@JohnMcPMS
Copy link
Member

@JohnMcPMS JohnMcPMS commented Feb 4, 2026

Implements #1488

Change

Adds the concept/value of priority to sources. This is an integer value (default 0) where greater numbers are sorted first. This is an editable value of a source. Priority has been added to the following interfaces:

  1. CLI commands (source add/edit/list/export)
  2. DSCv3 source resource
  3. DSCv2 source resource
  4. Configuration export
  5. COM source Add and Edit functionality
  6. PowerShell source objects
  7. Group policy JSON

Sources are sorted by priority in the list of sources, which has minor effects such as changing the order in source list and the order of available sources when constructing the default composite source. That default composite ordering has always had the effect of making equal match type/field results dependent on the order, but now the priority can affect the third order sorting.

The larger effect is when multiple sources return results for an operation targeting available packages (ex. install). In this case, if there is only one result amongst the sources at the highest returned priority, then that will be used instead of producing an error about multiple results. For example, if all sources return one result and the priorities are { Source A = 2, Source B = 1, Source C = 0 }, then the result from Source A would be installed without any additional user input (although a warning is output to indicate this has happened). But if the priorities are { Source A = 2, Source B = 2, Source C = 0 }, then an error similar to the existing one will be presented with only the A and B source results.

REST match criteria

A TODO has also been resolved in the REST source code that evaluates the match criteria of REST results so that they may be sorted properly amongst the winget-pkgs results. Previously they were always using default values (0s) which would cause them to be sorted first.

Validation

Added tests across the spectrum of use.

Microsoft Reviewers: Open in CodeFlow

@JohnMcPMS JohnMcPMS requested a review from a team as a code owner February 4, 2026 17:57
Type = DefaultSourceType,
TrustLevel = TrustedTrustLevel,
Explicit = true,
Priority = 42,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I see what you did there

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

On obviously arbitrary number for testing purposes only...

@mdanish-kh
Copy link
Contributor

But if the priorities are { Source A = 2, Source B = 2, Source C = 0 }, then an error similar to the existing one will be presented with only the A and B source results.

In such a scenario (for a single result as you mentioned), it may be worth checking if one of the sources returned version "Unknown" for the package (common with msstore), and if such that one implicitly gets the lower priority

florelis
florelis previously approved these changes Feb 5, 2026
florelis
florelis previously approved these changes Feb 5, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants