Skip to content
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

[DCR]: Better error reporting in API when certain credential provider is not installed #11435

Open
vlada-shubina opened this issue Dec 6, 2021 · 1 comment
Labels
Area:Authentication Area:ErrorHandling warnings and errors/log messages & related error codes. Functionality:Restore Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Product:dotnet.exe Type:DCR Design Change Request

Comments

@vlada-shubina
Copy link

vlada-shubina commented Dec 6, 2021

NuGet Product(s) Affected

dotnet.exe

Current Behavior

When certain credential provider is not installed, the API returns the following error on the request,

Details: NuGet.Protocol.Core.Types.FatalProtocolException: Unable to load the service index for source https://pkgs.dev.azure.com/<redacted>/<redacted>/_packaging/<redacted>/nuget/v3/index.json.
 ---> System.Net.Http.HttpRequestException: Response status code does not indicate success: 401 (Unauthorized).
   at System.Net.Http.HttpResponseMessage.EnsureSuccessStatusCode()
   at NuGet.Protocol.HttpSource.<>c__DisplayClass15_0`1.<<GetAsync>b__0>d.MoveNext()
--- End of stack trace from previous location ---
   at NuGet.Common.ConcurrencyUtilities.ExecuteWithFileLockedAsync[T](String filePath, Func`2 action, CancellationToken token)
   at NuGet.Common.ConcurrencyUtilities.ExecuteWithFileLockedAsync[T](String filePath, Func`2 action, CancellationToken token)
   at NuGet.Protocol.HttpSource.GetAsync[T](HttpSourceCachedRequest request, Func`2 processAsync, ILogger log, CancellationToken token)
   at NuGet.Protocol.ServiceIndexResourceV3Provider.GetServiceIndexResourceV3(SourceRepository source, DateTime utcNow, ILogger log, CancellationToken token)
   --- End of inner exception stack trace ---
   at NuGet.Protocol.ServiceIndexResourceV3Provider.GetServiceIndexResourceV3(SourceRepository source, DateTime utcNow, ILogger log, CancellationToken token)
   at NuGet.Protocol.ServiceIndexResourceV3Provider.TryCreate(SourceRepository source, CancellationToken token)
   at NuGet.Protocol.Core.Types.SourceRepository.GetResourceAsync[T](CancellationToken token)
   at NuGet.Protocol.PackageMetadataResourceV3Provider.TryCreate(SourceRepository source, CancellationToken token)
   at NuGet.Protocol.Core.Types.SourceRepository.GetResourceAsync[T](CancellationToken token)

The exception type is not different from other error, and it misses any details which would be useful to show to user.

Desired Behavior

Consider returning different exception type for this error, so it can be caught and handled differently.
Consider adding information that it happens due to credential provider is missing, and provide link to install it for popular providers (like Azure DevOps).

Then API consumers (dotnet new, dotnet restore) will be able to show this information to user. Current generic message is not enough to figure out that the underlying reason is missing provider and gives no guidance on how to resolve it.

Additional Context

It's a common case in dotnet new / dotnet SDK in general. The users need better guidance on this workflow.

dotnet/templating#4162
dotnet/templating#2212
dotnet/templating#1747 (comment)
dotnet/sdk#11640

@vlada-shubina vlada-shubina added Triage:Untriaged Type:DCR Design Change Request labels Dec 6, 2021
@nkolev92 nkolev92 added Pipeline:Icebox Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. labels Dec 9, 2021
@nkolev92
Copy link
Member

Team Triage:
We agree that the current error message does not provide enough detail on its own.

In order to provide a more actionable message, NuGet would need to try to recognize the type of the feed it is, and potentially map it to a credential provider (which is beyond NuGet's control).
If we were to add a special case for Azure Artifacts, do we need to handle other feeds?

The solution probably needs to be at the application layer rather than an API one.

@nkolev92 nkolev92 added Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. and removed Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Triage:NeedsTriageDiscussion labels Apr 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area:Authentication Area:ErrorHandling warnings and errors/log messages & related error codes. Functionality:Restore Priority:3 Issues under consideration. With enough upvotes, will be reconsidered to be added to the backlog. Product:dotnet.exe Type:DCR Design Change Request
Projects
None yet
Development

No branches or pull requests

4 participants