dapr / dotnet-sdk

Dapr SDK for .NET
Apache License 2.0
1.11k stars 335 forks source link

Surface information about failed `InvokeMethodAsync` (and others) failures #1377

Open atrauzzi opened 2 hours ago

atrauzzi commented 2 hours ago

Expected Behavior

I would have liked to have somehow obtained more easily viewed errors when a call to the sidecar fails. Including telemetry and structured logs so that I can eventually get the feedback in Aspire.

Actual Behavior

No log output, nothing helpful in exceptions. I have to see HTTP JSON output from the sidecar just to know what went wrong.

Steps to Reproduce the Problem

Configure a dapr HTTPEndpoint (not an Aspire HTTP endpoint :laughing:), make sure it uses https and point it to something that is hosting with an invalid certificate.

Try to call the HTTPEndpoint via dapr.

WhitWaldo commented 2 hours ago

More to this issue in particular, the request was returning as a 500 despite being a certificate validation failure, which should instead be in the 400s. Also, the SDK returned nothing about what the issue itself was even though the same request done manually through the service invocation HTTP API yielded the following (redacted) error (which itself also was returned as a 500):

{ "errorCode": "ERR_DIRECT_INVOKE", "message": "failed to invoke, id: dapr-app-id, err: Get \"https://auth.justanotherwebsite.com/api/v3/admin/version\": tls: failed to verify certificate: x509: certificate is not valid for any names, but wanted to match auth.justanotherwebsite.com" }

The SDK should instead surface whatever errors are provided by the runtime to help in debugging issues without having to resort to methods outside of the SDK.