Skip to content

Send empty WinGet searches through the CLI instead of COM - #5822

Merged
Gabriel Dufresne (GabrielDuf) merged 2 commits into
mainfrom
fix/5812-empty-winget-search-cli
Nov 23, 2026
Merged

Gabriel Dufresne (GabrielDuf) merged 2 commits into
mainfrom
fix/5812-empty-winget-search-cli

Conversation

@GabrielDuf

@GabrielDuf Gabriel Dufresne (GabrielDuf) commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Root cause

#5641 tried to make an empty Discover search list a private WinGet REST source by sending a CatalogDefault selector with an empty value through COM. That never reached the server: WinGet's COM layer (PackageCatalog.cpp, PopulateSearchRequestFromVector) skips every filter and selector whose value is empty ("If the caller did not add a value it can't actually be used to filter or include anything so just ignore it"). So COM kept sending the same request as before:

{"FetchAllManifests": true, "MaximumResults": 100}

Winget-Repo, the reporter's server, answers that with no packages. It only lists everything when the body carries a query, which is what winget search "" sends:

{"MaximumResults": 100, "Query": {"KeyWord": "", "MatchType": "Substring"}}

The reporter's Find-WinGetPackage -Query '' test in #5639 goes through the same COM layer, and it came back empty for the same reason.

Fix

COM has no way to send an empty keyword, so:

  • NativeWinGetHelper.FindPackages_UnSafe hands an empty query to the CLI helper it already uses as its fallback for updates and installed packages. That helper searches each source with search "" --source <name> --count 100. The dead CatalogDefault branch is removed; non-empty searches keep their Name/Id/Moniker filters.
  • WinGetCliHelper: when winget source export exited non-zero or listed nothing, the empty search used to search no source at all and showed the same "No results". It now falls back to the sources UniGetUI already knows (ChooseBrowseSources).

refs #5812

An empty Discover search still listed nothing from a private WinGet REST
source after #5641. WinGet's COM layer (PackageCatalog.cpp,
PopulateSearchRequestFromVector) skips every filter and selector whose
value is empty, so the CatalogDefault "" selector added there never became
a Query. COM kept sending {"FetchAllManifests":true,"MaximumResults":100},
which servers such as Winget-Repo answer with no packages: it only lists
everything for Query {KeyWord:"", MatchType:"Substring"}, the body that
`winget search ""` sends. The reporter's Find-WinGetPackage -Query '' test,
which goes through the same COM layer, came back empty for this reason.

COM has no way to send an empty keyword, so NativeWinGetHelper now hands an
empty query to the CLI helper it already uses as its fallback for updates
and installed packages. That helper searches each source with
`search "" --source <name> --count 100`. The dead CatalogDefault branch is
removed; non-empty searches keep their Name/Id/Moniker filters.

The CLI helper used to search no source at all when `winget source export`
failed, which showed the same "No results". It now falls back to the
sources UniGetUI already knows when the export exits non-zero or lists
none.

Verified against a port of Winget-Repo 2.9.4's manifestSearch on a local
HTTPS REST source with winget 1.29.380 (the reporter's version): the
unfixed app's empty search sent FetchAllManifests and got 0 packages from
that source, the fixed app sent the empty Query and listed all of them.

Fixes #5812

Co-Authored-By: Claude Opus 5.5 <[email protected]>

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🔵 Needs a closer look

The real empty-query CLI search needs human confirmation on the reporter’s Windows/private WinGet REST setup because prior fixes failed there and current tests cover only mocked delegation and source selection.

No open issues 🎉

What changed in this PR

This PR addresses empty Discover searches returning no results for private WinGet repositories (#5812), replacing the ineffective COM approach from #5641 with CLI searches.

Changes:

  • Route empty searches through the CLI while preserving COM filters for non-empty queries.
  • Fall back to UniGetUI’s known sources when CLI source export fails or returns no sources.
  • Update regression tests for CLI delegation and source fallback behavior.
File Description
src/​UniGetUI.PackageEngine.Tests/​WinGetManagerTests.cs Tests empty-query CLI delegation and retained non-empty search fields.
src/​UniGetUI.PackageEngine.Tests/​WinGetCliParsingTests.cs Tests source selection after successful, failed, or empty exports.
src/​UniGetUI.PackageEngine.Managers.WinGet/​ClientHelpers/​WinGetCliHelper.cs Adds known-source fallback for empty-query browsing.
src/​UniGetUI.PackageEngine.Managers.WinGet/​ClientHelpers/​NativeWinGetHelper.cs Delegates empty queries to the CLI and removes the ineffective COM selector.

Review effort: Balanced

@randy-but-a-ro randy-but-a-ro Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🤖 Pull request was approved automatically: the AI review is complete and all its review threads are resolved. 🎉

Integration Details
{
	"deliveryId": "ca590d56-e770-11f1-8c00-0f0ff23d805f",
	"headSha": "8e2f0490ad77cd65d7f8f445157c49835e9ccd9a",
	"reviewer": "copilot-pull-request-reviewer[bot]"
}

@GabrielDuf
Gabriel Dufresne (GabrielDuf) merged commit f52a693 into main Nov 23, 2026
12 checks passed
@GabrielDuf
Gabriel Dufresne (GabrielDuf) deleted the fix/5812-empty-winget-search-cli branch November 23, 2026 19:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working winget

Development

Successfully merging this pull request may close these issues.

2 participants