Repository navigation
Send empty WinGet COM searches as a substring query - #5641
Merged
Merged
Conversation
For an empty Discover query the COM helper built FindPackagesOptions with
no filters and no selectors, only a result limit. In winget's COM layer
that becomes a SearchRequest with no Query, no Inclusions and no Filters,
so IsForEverything() is true and a REST source receives a manifestSearch
body of {"MaximumResults":100,"FetchAllManifests":true} with no Query.
FetchAllManifests is optional server-side, and some REST servers answer
it with zero matches and no error, while `winget search ""` works.
The CLI turns the empty positional query into Query =
RequestMatch(Substring, ""), which servers treat as matching everything.
The helper now does the same through a CatalogDefault selector with an
empty value and ContainsCaseInsensitive, keeping the result limit. It
must be a selector, because COM rejects CatalogDefault in Filters with
E_INVALIDARG. Non-empty queries are unchanged.
The per-search plan moved into a pure GetSearchRequests(query) so the
choice can be tested without COM activation.
Fixes #5639
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Contributor
There was a problem hiding this comment.
🟢 Approval recommended
No active review issues remain for the change aligning empty WinGet COM searches with CLI behavior.
No open issues 🎉
What changed in this PR
Aligns empty WinGet COM searches with CLI behavior to address empty Discover results from private REST repositories reported in #5639.
Changes:
- Uses an empty
CatalogDefaultsubstring selector while preserving the per-source result limit and existing non-empty search behavior. - Extracts request planning into a testable helper and adds regression tests for empty and non-empty queries.
| File | Description |
|---|---|
src/UniGetUI.PackageEngine.Tests/WinGetManagerTests.cs |
Adds tests for selector, filter, and result-limit choices. |
src/UniGetUI.PackageEngine.Managers.WinGet/ClientHelpers/NativeWinGetHelper.cs |
Extracts request planning and applies the empty-query selector to COM searches. |
Review effort: Balanced
There was a problem hiding this comment.
🤖 Pull request was approved automatically: the AI review is complete and all its review threads are resolved. 🎉
Integration Details
{
"deliveryId": "96d23850-d469-11f1-900c-fde14c7c4786",
"headSha": "c0c58881859564556d648b773db29929020c20cc",
"reviewer": "copilot-pull-request-reviewer[bot]"
}
This was referenced Oct 30, 2026
martesi
added a commit
to martesi/UniGetUI
that referenced
this pull request
Nov 2, 2026
Use a catalog-default selector for empty COM searches. Restore the bounded CLI search and installer URL handling, and remove the unsupported Agent broker path from Classic. Upstream-Commit: 2a03ddc Upstream-PR: Devolutions#5641
martesi
added a commit
to martesi/UniGetUI
that referenced
this pull request
Nov 2, 2026
Classic-Source-Commit: 1e22e54 Upstream-Commit: 2a03ddc Upstream-PR: Devolutions#5641
4 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
For an empty Discover query,
NativeWinGetHelper.FindPackages_UnSafe(the COM path) built aFindPackagesOptionswith no Filters and no Selectors, onlyResultLimit. In winget's COM layer that becomes aSearchRequestwith no Query, no Inclusions and no Filters, soIsForEverything()is true. For a REST source the 1.0 serializer then sends a manifestSearch body of{"MaximumResults":100,"FetchAllManifests":true}with no Query.FetchAllManifestsis optional on the server side, and the reporter's Winget-Repo server answers it with zero matches and no error, which matches the log (search began on the catalog and finished with nothing found).winget search ""behaves differently: the CLI turns the empty positional query intoSearchRequest.Query = RequestMatch(Substring, ""), so the REST body carriesQuery {KeyWord:"", MatchType:"Substring"}, and that server treats an empty keyword as matching everything.WinGetCliHelperandPingetCliHelperalready passsearch ""per source, so only the COM helper took the "fetch everything" path. Nothing caught it because the pre-indexed community winget source honours an everything-request.Fix
NativeWinGetHelpernow sends an empty query the way the CLI does: a Selector withPackageMatchField.CatalogDefault, an empty value andContainsCaseInsensitive, keepingResultLimit = SearchLimits.MaxEmptyQueryResultsPerSource. In winget's COM layer aCatalogDefaultselector maps toSearchRequest.QueryandContainsCaseInsensitivemaps toMatchType::Substring. It has to be a Selector, not a Filter, because COM rejectsCatalogDefaultin Filters withE_INVALIDARG. Non-empty queries are unchanged (Name/Id/Moniker filters, no limit).The per-search plan moved into a pure static
NativeWinGetHelper.GetSearchRequests(query)returningNativeSearchRequest(Field, IsSelector, ResultLimit)records, so the choice is testable without COM activation. The task dictionary key changed fromPackageMatchField?toPackageMatchFieldbecause every request now has a field.Verification
dotnet buildofUniGetUI.PackageEngine.Tests(x64): 0 errors; warnings are existing ones in untouched files.dotnet format whitespaceverify: exit 0.dotnet format stylereports no diagnostics in the changed files (the solution-wide style check already exits 2 onmainfrom unrelated IDE0044/IDE0060 warnings).WinGetManagerTests.NativeWinGetHelperSearches*: 2 run, 2 passed.winget search "" --source winget --count 5lists packages, andFind-WinGetPackage -Query ''(Microsoft.WinGet.Client 1.29.380, which builds the same emptyCatalogDefaultselector through COM) returned 100 packages. So COM accepts the selector and the community source does not regress.winget search --query "", which produces the same REST request body. The NativeAOT publish was not run; the change adds no reflection or interop surface. The full suite is left to CI.Regression test
WinGetManagerTests.NativeWinGetHelperSearchesEmptyQueryThroughCatalogDefaultSelectorWinGetManagerTests.NativeWinGetHelperSearchesQueryByNameIdAndMonikerFiltersWithout the fix they fail to compile (
GetSearchRequestsis missing); with it both pass. They check the request plan, not the COM options or the REST body built from it; swapping the Selectors/Filters branch insideFindPackages_UnSafewould not be caught, and a deeper test would need WinGet COM activation. This is not a UI change.Non-blocking review notes
// Name filtercomment andFilterNamevariable now also describe theCatalogDefaultselector, so they are slightly misleading. The comment is old and only moved.FetchAllManifestsis arguably the server's gap; matching the CLI's request is the robust client-side answer.Closes #5639