question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Grpc.Core.RpcException when remote invocation results in BadRequest

See original GitHub issue

Expected Behavior

The client sdk should be able to handle HTTP 400 Bad Request and make the request available to the calling application

Actual Behavior

When the app returns a HTTP400 or BadRequest object the dapr client fails with an exception.

Steps to Reproduce the Problem

Small modification of https://github.com/dapr/dotnet-sdk/blob/master/samples/AspNetCore/ControllerSample/Controllers/SampleController.cs to add the following method to return a BadRequest

/// Do
[HttpPost("do")]
public IActionResult Do(int value)
{
    Console.WriteLine($"Doing {value}"); 
    return BadRequest(new
    {
        value = value
    });
}

When calling the method on the client via

var a = await client.InvokeMethodAsync<object, Account>("routing", "do", data, httpExtension);

we are getting an exception

== APP == DepositUsingServiceInvocation

== APP == invoking

== APP == Unhandled exception. Grpc.Core.RpcException: Status(StatusCode=Internal, Detail="Bad Request")
== APP ==    at Dapr.Client.DaprClientGrpc.MakeGrpcCallHandleError[TResponse](Func`2 callFunc, CancellationToken cancellationToken) in /dotnet-sdk/src/Dapr.Client/DaprClientGrpc.cs:line 585

It seems there is no handling in the client sdk https://github.com/dapr/dotnet-sdk/blob/master/src/Dapr.Client/DaprClientGrpc.cs#L584

RELEASE NOTE: N/A

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:32 (32 by maintainers)

github_iconTop GitHub Comments

1reaction
youngbuparkcommented, Sep 16, 2020

moving back to dotnet-sdk. The fix for grpc-dotnet has been merged - https://github.com/grpc/grpc-dotnet/pull/1046 new version of grpc-dotnet will be released by this week or early next week. then we will use this version to fix this problem.

1reaction
yaron2commented, Sep 8, 2020

IMO we need to make sure we return the following information to the caller when invoking HTTP services, uniformly:

  1. Response text
  2. Status code
  3. Headers
Read more comments on GitHub >

github_iconTop Results From Across the Web

Exception when calling gRPC server from .Net Framework ...
TryParseRequest(ReadResult result, Boolean& endConnection) at Microsoft.AspNetCore.Server.Kestrel.Core.Internal.Http.HttpProtocol.
Read more >
Troubleshoot gRPC on .NET
Call insecure gRPC services with .NET Core client. The .NET gRPC client can call insecure gRPC services by specifing http in the server...
Read more >
Namespace Grpc.Core | Google.Cloud.Asset.V1Beta1
A description of a remote method. RpcException. Thrown when remote procedure call fails. Every RpcException is associated with a resulting Status of the...
Read more >
Implementing Microservices with gRPC and .NET Core 3.1
The gRPC framework proposes the RPC model, which is a model where a client invokes a remote procedure that will be executed on...
Read more >
Handling gRPC exception correctly server side
Return an RpcException with the correct gRPC status code (depends on the type of exception handled). In the case of a RpcException, we...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found