dapr / java-sdk

Dapr SDK for Java
Apache License 2.0
259 stars 207 forks source link

Http Binding returning wrong status code #1127

Closed rochabr closed 2 weeks ago

rochabr commented 2 weeks ago

Actual Behavior

Upgrading the Java Dapr SDK from 1.11 to 1.12 changed the exception handling behaviour in Http Binding where the errorIfNot2XX flag is set to false.

ie: When service A calls service B and B throws an error:

Dapr SDK 1.11 A gets the error status code (eg 400) and the error response body.

image

Dapr SDK 1.12 A gets the status code (eg 405) as part of the response body itself and overall http request status is 200.

image

They are mentioning that they now need to parse the response body manually in order to evaluate whether the call fetched a successful response or an exception. Here is the code:

Map<String, String> requestMetaData = new HashMap<>();
requestMetaData.put("errorIfNot2XX", "false");

daprClient.invokeBinding(
        "fetch-documents-using-group-name",
        DaprHttpMethod.POST,
        body,
        requestMetaData,
        Void.class);
mono.block();

Is this a bug or was this change planned? This is likely due to the way the change in the java sdk returning status object and not httpStatusCode .

artursouza commented 2 weeks ago

The change to make this work was not added to master branch after 1.11, so it was not added to 1.12. I am working to porting this change over, just need to re-do some of it given all the code conflicts. Sorry.