DuendeSoftware / Support

Support for Duende Software products
21 stars 0 forks source link

Include inner exception when failing to serve the GetDiscoveryDocumentAsync document? #1294

Closed niklasenskog closed 3 months ago

niklasenskog commented 3 months ago

Which version of Duende IdentityServer are you using? 7.0.4

Which version of .NET are you using? net8.0

Describe the bug Following the guided path at https://docs.duendesoftware.com/identityserver/v7/quickstarts/1_client_credentials/ I run into the following issue when running the client project.

Error connecting to https://localhost:5001/.well-known/openid-configuration. The SSL connection could not be established, see inner exception..

This is not a bug of course, more of a question/suggestion.

No doubt the error is on my side, but I think client developers in general would benefit if that inner exception was included in the (client.GetDiscoveryDocumentAsync(...)).Error

Then again, there's a fine line between leaking information and providing api developers with help.

To Reproduce Hard to tell, all I did was following the guide, ineptly it seems.

Expected behavior I would have loved to see that inner exception.

RolandGuijt commented 3 months ago

There was no error on your side. The Error property is just very simple it nature: it just reflects what is in the Message property of the exception that was thrown. And only the value of that property is written to the console. In this case it accurately describes what went wrong.

The DiscoveryEndpointResponse object allows access to the original exception. If you would like to see the details in the console you could write something like this:

var disco = await client.GetDiscoveryDocumentAsync("https://localhost:5001");
if (disco.IsError)
{
    Console.WriteLine(disco.Error);
    if (disco.Exception?.InnerException != null)
    {
        Console.WriteLine(disco.Exception.InnerException.Message);
    }
    return;
}
niklasenskog commented 3 months ago

Excellent, thanks!