rust-sdk icon indicating copy to clipboard operation
rust-sdk copied to clipboard

`save_state` function lacks metadata argument, resulting in states being stored as serialized strings instead of objects.

Open ruokun-niu opened this issue 1 year ago • 0 comments

Describe the feature/proposal

Hi, I have a Rust project that tries to save a state into a mongo state store using the save_state function and queries a particular state value using query_state_alpha1. However, I noticed that when I queried the result when I specified a condition, the query just returns an empty result set. When I set condition to be an empty json, the result set contained all of the entries in the state store collection. This indicates that the data was successfully saved into the state store and the query state API is working.

I inspected the data that was inserted into the save store by exporting the data in my mongo collection, and I noticed one weird behavior: I formatted my state values as json objects, but these values become a serialized json string when they are saved in the state store. As a result, this prevents me from retrieving any entries when querying with a condition.

Users of other Dapr SDKs have also reported similar issues, as seen in https://github.com/dapr/dotnet-sdk/issues/783. However, as mentioned in this issue, for the Dapr Dotnet SDK, the users are able to resolve this issue by setting the content type to json in the metadata. It seems like the Rust Dapr SDK does not support this functionality at the moment (https://docs.rs/dapr/0.15.1/dapr/client/struct.Client.html#method.save_state).

Our team was able to temporarily resolve this issue by sending HTTP requests (and modifying the metadata of the request) to the dapr sidecar.  

Release Note

RELEASE NOTE:

ruokun-niu avatar Oct 18 '24 22:10 ruokun-niu