Repository navigation
Fix package type query parameter for V3 search, add capability check - #7395
Conversation
|
Thanks @martinrrm! Do you mind reapproving? I just fixed the unit test. |
nkolev92
left a comment
There was a problem hiding this comment.
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.
13e4fda to
88480bf
Compare
88480bf to
1620253
Compare
nkolev92
left a comment
There was a problem hiding this comment.
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.
|
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
1620253 to
8db7b75
Compare
zivkan
left a comment
There was a problem hiding this comment.
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.
Bug
Fixes: NuGet/Home#8915
Related (closed) prior attempt: #5991
Description
PackageSearchResourceV3was sending the package-type filter using the legacypackageTypeFilterquery parameter. TheSearchQueryService/3.5.0specification usespackageType. As a result,SearchFilter.PackageTypeshas 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
packageType=(single value) instead ofpackageTypeFilter=.SearchQueryService350entry is fetched separately. WhenSearchFilter.PackageTypesis set on a source that does not advertiseSearchQueryService/3.5.0, the resource throwsNotSupportedExceptioninstead 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.What this PR explicitly does NOT do (and why)
SearchFilter.PackageTypes(IEnumerable<string>→string)LocalPackageSearchResourceNotSupportedExceptiongives the front-end a clean signal to skip non-capable sources.Behavior change
Callers who previously set
SearchFilter.PackageTypesagainst a V3 source that does not advertiseSearchQueryService/3.5.0used to get unfiltered results (silently broken). They will now get aNotSupportedException. This is a strict correctness improvement: the caller's intent was never being honoured before, and now they get an explicit signal.PR Checklist