dapr / dapr/dotnet-sdk

GetStateAsync throws exception if key not found when using json contentType

Open
#999 5 comments 0 reactions 0 assignees View on GitHub
Dominant language
C#
Stars
1.2k
Forks
378
Avg merge
1d 22h
Merged PRs (30d)
5

Description

## Ask your question here
I am using `redis` for state store component with `RedisJSON` module, and when getting state with `contentType` metadata set to `application/json`, method `GetStateAsync` on the dapr client throws the following exception if the key doesn't exist:
```
Error when trying to Retrieve ... with Id: ..."Error","@x":"Dapr.DaprException:
State operation failed: the Dapr endpoint indicated a failure. See InnerException for details.
Grpc.Core.RpcException: Status(StatusCode=\"Internal\", Detail=\"fail to get <...> from state store local: redis: nil\")
at Dapr.Client.DaprClientGrpc.GetStateAsync[TValue](String storeName, String key, Nullable`1 consistencyMode, IReadOnlyDictionary`2 metadata, CancellationToken cancellationToken)
```

Is this an intended behavior or more like a bug? When not using any metadata the return value from `GetStateAsync` is `null` with no exception thrown if the key doesn't exist.

Thanks!

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.