-
Notifications
You must be signed in to change notification settings - Fork 1.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clean up error experience when downloading non-tools #43045
Clean up error experience when downloading non-tools #43045
Conversation
src/Cli/dotnet/NugetPackageDownloader/NuGetPackageDownloader.cs
Outdated
Show resolved
Hide resolved
Co-authored-by: Chet Husk <baronfel@users.noreply.github.com>
60d634b
to
ac56ea8
Compare
Looking at the image in the description (thank you!) the part that stands out to me is that we know what the failure is now. Can we prevent rendering everything after |
Does this search work if the package is unlisted and the version is explicitly specified? Or worse: publish a .NET tool package, publish a non-tool package with the same name and a higher version, unlist the .NET tool version of the package, and try to install the tool with an explicit version. |
I have no idea whether unlisting the package affects this API. I think I have an idea for testing and will try to do that today if possible.
I don't think having a higher-versioned non-tool package of the same name would be a problem in this case. It should find the latest version that matches the criteria, which in this case means having the dotnet tool package type. |
Yes! I tested with the elemental.sysinfotool package, as that's what we've used for testing unlisted packages previously, and it can still successfully install it.
|
var results = await searchResource.SearchAsync(packageId.ToString(), new SearchFilter(includePrerelease: includePreview, filter: SearchFilterType.IsLatestVersion) | ||
{ | ||
PackageTypes = [NuGet.Packaging.Core.PackageType.DotnetTool.Name] | ||
}, skip: 0, take: 10, log: _verboseLogger, cancellationToken: cancellationToken).ConfigureAwait(false); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Holy moly. The formatting here confused me so bad. Took me a while to figure out the curly braces were an initializer list for the new SearchFilter
. Might be a bit easer to read as:
var results = await searchResource.SearchAsync(packageId.ToString(), new SearchFilter(includePrerelease: includePreview, filter: SearchFilterType.IsLatestVersion) | |
{ | |
PackageTypes = [NuGet.Packaging.Core.PackageType.DotnetTool.Name] | |
}, skip: 0, take: 10, log: _verboseLogger, cancellationToken: cancellationToken).ConfigureAwait(false); | |
var searchFilter = new SearchFilter(includePrerelease: includePreview, filter: SearchFilterType.IsLatestVersion) { PackageTypes = [NuGet.Packaging.Core.PackageType.DotnetTool.Name] }; | |
var results = await searchResource.SearchAsync(packageId.ToString(), searchFilter, skip: 0, take: 10, log: _verboseLogger, cancellationToken: cancellationToken).ConfigureAwait(false); |
I tried running this PR in a dogfood environment and see a completely different error:
|
When I first made the PR, I got the results I specified in the description. @baronfel suggested using a strongly-typed version of the same idea, and since I didn't like how hacky my original version was, I committed it, but as I continued testing, I found: That means this PR currently does nothing. The error you found was what happens when this PR fails to have the desired effect. I'm still waiting to find out whether there's a good reason that API is consistently returning null. |
Thanks, that makes sense and I understand better now where @marcpopMSFT wanted me to pick this up |
Think I figured out the rest. If the package already exists, we assume it is a tool package and then we can fail. Updating the PR with an additional check that should take care of the |
@joeloff, can you make sure to re-test:
before merging? I only tested with the version prior to this, which was different enough I could easily imagine it no longer being true. |
Yeah, I'll retest that |
I can't approve, but I think this looks good to me. Might consider adding a couple tests, though |
@baronfel here's a screenshot of the new error experience |
Ok you're going to hate me but if we know the package isn't a tool we shouldn't show the rest of the exception (everything from line 2 onwards). |
I was thinking the same thing after I pasted the screenshot, so we're on the same page |
I seem to remember you made the same comment to me, and after looking around, I found that I could just change |
Yup, the extra text is coming from |
Remaining errors were the known container errors |
This change appears to be the source of #43651 and has broken tool installation for non-NuGet.org package feeds that are used as proxies, such as JFrog Artifactory. |
Fixes #37010
This is the new error experience:
This roughly works, but the current version feels pretty hacky to me, and I'm not a fan of that. In particular, where did magic 139 come from? Apparently it's the "failed to find a tool" message length, but I didn't see how I could access the real message, so that was the best I could do for now.