Throw exception when asking for FirstWrite OCC without ETag
- 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
Assessment
This issue has not been assessed yet.