Skip to content

Fix package type query parameter for V3 search, add capability check - #7395

Merged
zivkan merged 1 commit into
NuGet:devfrom
liliankasem:liliankasem/bug/package-type-search-query
Jun 10, 2026
Merged

zivkan merged 1 commit into
NuGet:devfrom
liliankasem:liliankasem/bug/package-type-search-query

Conversation

@liliankasem

Copy link
Copy Markdown
Contributor

Bug

Fixes: NuGet/Home#8915
Related (closed) prior attempt: #5991

Description

PackageSearchResourceV3 was sending the package-type filter using the legacy packageTypeFilter query parameter. The SearchQueryService/3.5.0 specification uses packageType. As a result, SearchFilter.PackageTypes has been silently ignored by nuget.org and other compliant V3 sources for as long as the property has existed publicly.

This PR is intentionally scoped to the bug fix plus capability detection. The broader API redesign and local-source support discussed in #5991 are deferred to follow-up issues so this PR can land without re-litigating the same design conversation.

What this PR does

  1. Send the correct query parameter. packageType= (single value) instead of packageTypeFilter=.
  2. Capability detection via the service index. A new internal SearchQueryService350 entry is fetched separately. When SearchFilter.PackageTypes is set on a source that does not advertise SearchQueryService/3.5.0, the resource throws NotSupportedException instead of silently returning unfiltered results that the caller assumes are filtered. This addresses the primary concern raised by @zivkan in Add support for package type queries in both local and remote sources #5991.
  3. Endpoint routing. Filtered queries are routed only to capable endpoints; unfiltered queries continue to use the existing endpoint set, so behavior is unchanged when no filter is requested.
  4. Tests for: correct query parameter, capability rejection, and unchanged behavior when no filter is requested.

What this PR explicitly does NOT do (and why)

Deferred change Reason
Reshape SearchFilter.PackageTypes (IEnumerable<string> → string) This would be a breaking public API change. The current shipped API is preserved; only the first value is sent, matching the protocol contract. The reshape can be tracked separately.
Add package-type filtering to LocalPackageSearchResource Independent change with its own design considerations (e.g. how nuspec package types map). Not required to fix the reported bug.
Decide aggregated-source ("All") behavior when one source is non-capable Per the discussion in #5991, this is a front-end concern. NotSupportedException gives the front-end a clean signal to skip non-capable sources.

Behavior change

Callers who previously set SearchFilter.PackageTypes against a V3 source that does not advertise SearchQueryService/3.5.0 used to get unfiltered results (silently broken). They will now get a NotSupportedException. This is a strict correctness improvement: the caller's intent was never being honoured before, and now they get an explicit signal.

PR Checklist

  • Meaningful title, helpful description and a linked NuGet/Home issue
  • Added tests
  • Link to an issue or pull request to update docs if this PR changes settings, environment variables, new feature, etc. (no user-facing settings changed; the fix is in the protocol layer)

@dotnet-policy-service dotnet-policy-service Bot added the Community PRs created by someone not in the NuGet team label May 14, 2026
@liliankasem
liliankasem marked this pull request as ready for review May 14, 2026 22:47
@liliankasem
liliankasem requested a review from a team as a code owner May 14, 2026 22:47
@liliankasem
liliankasem requested review from jebriede and nkolev92 May 14, 2026 22:47
martinrrm
martinrrm previously approved these changes May 18, 2026

@martinrrm martinrrm 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.

lgtm

@liliankasem

Copy link
Copy Markdown
Contributor Author

Thanks @martinrrm! Do you mind reapproving? I just fixed the unit test.

@nkolev92 nkolev92 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sorry for the delay review.

@NuGet/nuget-client It'd be great to get some more thoughts on the behavior for search resources with package type.

@jeffkl jeffkl self-assigned this May 26, 2026
@dotnet-policy-service dotnet-policy-service Bot added the Status:No recent activity PRs that have not had any recent activity and will be closed if the label is not removed label Jun 2, 2026
@liliankasem
liliankasem force-pushed the liliankasem/bug/package-type-search-query branch from 13e4fda to 88480bf Compare June 2, 2026 23:44
@dotnet-policy-service dotnet-policy-service Bot removed the Status:No recent activity PRs that have not had any recent activity and will be closed if the label is not removed label Jun 2, 2026
jeffkl
jeffkl previously approved these changes Jun 3, 2026
@jeffkl
jeffkl requested review from nkolev92 and zivkan June 3, 2026 21:15
@liliankasem
liliankasem force-pushed the liliankasem/bug/package-type-search-query branch from 88480bf to 1620253 Compare June 4, 2026 18:12
nkolev92
nkolev92 previously approved these changes Jun 8, 2026

@nkolev92 nkolev92 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I think we need to rethink the throwing when package type filtering is unsupported without a way to check prior to the call, but maybe we can handle that internally.

Same thing applies to handling package type filtering for local resources and potentially throwing for V2 feeds.

@nkolev92

nkolev92 commented Jun 8, 2026

Copy link
Copy Markdown
Member

Filed the follow-up from my review here: NuGet/Home#14936 — covers both the pre-call capability discovery question and the cross-resource parity (V2 / local) decision, since the two are coupled.

PackageSearchResourceV3 was sending the package type filter using the
legacy 'packageTypeFilter' query parameter. The SearchQueryService/3.5.0
specification uses 'packageType'. This meant SearchFilter.PackageTypes
was silently ignored by nuget.org and other compliant V3 sources.

Changes:
* Send 'packageType=' (single value) instead of 'packageTypeFilter='.
* Detect capability via the SearchQueryService/3.5.0 service-index entry.
  When SearchFilter.PackageTypes is set on a source that does not
  advertise this resource, throw NotSupportedException instead of
  returning unfiltered results that the caller assumes are filtered.
* Route filtered queries only to capable endpoints; fall back to all
  endpoints when no filter is requested.

Scope notes (deferred to follow-up work):
* SearchFilter.PackageTypes is left as IEnumerable<string> for now to
  avoid a breaking public API change. Only the first value is sent,
  matching the protocol contract.
* Local source (LocalPackageSearchResource) package type filtering is
  not addressed here.

Refs: NuGet#5991, NuGet/Home#8915
@liliankasem
liliankasem force-pushed the liliankasem/bug/package-type-search-query branch from 1620253 to 8db7b75 Compare June 9, 2026 17:25
@liliankasem

Copy link
Copy Markdown
Contributor Author

@nkolev92 @jeffkl do you mind reapproving - had to rebase again :)

@Nigusu-Allehu
Nigusu-Allehu self-requested a review June 9, 2026 23:39

@zivkan zivkan left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I was on vacation, so I wasn't able to review sooner. I have changes that I think should be made before this ships to customers, but I'll do it myself in another PR. Just adding feedback for the learning opportunity.

@zivkan
zivkan enabled auto-merge (squash) June 10, 2026 01:06
@zivkan
zivkan merged commit 2b4dd56 into NuGet:dev Jun 10, 2026
17 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Community PRs created by someone not in the NuGet team

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature ask client side -- Surface PackageType query parameter in the NuGet.org search API

5 participants