dapr / dapr/dotnet-sdk

Throw exception when asking for FirstWrite OCC without ETag

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

Description

## Describe the proposal

Currently, the SDK allows you to make the following call:

```c#
await daprClient.SaveStateAsync(
"storename",
"key",
new Foo(),
new StateOptions
{
Concurrency = ConcurrencyMode.FirstWrite
});
```

The problem with the call is that we're asking Dapr to do something impossible. FirstWrite OCC will only work if we send an ETag along with the request. `SaveStateAsync` will never send the ETag, for that you need to call `TrySaveStateAsync`.

The call will succeed but it won't use FirstWrite OCC. There are other situations where you can give Dapr state management a command/hint that cannot be fulfilled by the underlying state store, such as asking for strong consistency if the data store doesn't support it. However, the FirstWrite issue can be caught early at the SDK level.

I propose throwing an exception with a clear message explaining that you need ETag/TrySaveState to use FirstWrite.

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.