Pass per-operation StateItem metadata in async execute_state_transaction#1132
Conversation
The async client omitted metadata= when building StateItem, unlike the sync client (added in dapr#791), so per-operation metadata e.g. outbox.projection and CloudEvent attribute overrides for the transactional outbox was silently dropped. Mirrors the sync client Signed-off-by: LilDojd <yawner@pm.me> Change-Id: I568579c8d1c1d3599bf1fd03dcd1587b6a6a6964
There was a problem hiding this comment.
Pull request overview
This PR fixes the async gRPC client’s execute_state_transaction to include per-operation StateItem metadata (matching the sync client), preventing metadata like outbox.projection from being dropped and breaking the transactional outbox pattern.
Changes:
- Add per-operation
metadatawhen buildingStateItemindapr.aio.clients.grpc.client.DaprGrpcClientAsync.execute_state_transaction. - Extend sync and async client tests to assert that per-operation metadata is received by the sidecar.
- Update the fake Dapr sidecar test server to record per-operation metadata from transaction requests for verification.
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
dapr/aio/clients/grpc/client.py |
Passes o.metadata into the per-operation StateItem for async state transactions. |
tests/clients/fake_dapr_server.py |
Captures operation.request.metadata per key during ExecuteStateTransaction to support assertions. |
tests/clients/test_dapr_grpc_client.py |
Adds sync test assertions verifying per-operation transaction metadata is preserved. |
tests/clients/test_dapr_grpc_client_async.py |
Adds async test assertions verifying per-operation transaction metadata is preserved. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
|
@LilDojd Thanks for the contribution! |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1132 +/- ##
==========================================
- Coverage 86.63% 82.13% -4.50%
==========================================
Files 84 117 +33
Lines 4473 9612 +5139
==========================================
+ Hits 3875 7895 +4020
- Misses 598 1717 +1119 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
…ion (#1132) (#1133) The async client omitted metadata= when building StateItem, unlike the sync client (added in #791), so per-operation metadata e.g. outbox.projection and CloudEvent attribute overrides for the transactional outbox was silently dropped. Mirrors the sync client Change-Id: I568579c8d1c1d3599bf1fd03dcd1587b6a6a6964 (cherry picked from commit 2f0ab79) Signed-off-by: LilDojd <yawner@pm.me> Signed-off-by: dapr-bot <dapr-bot@users.noreply.github.com> Co-authored-by: George <37330594+LilDojd@users.noreply.github.com>
Description
Pass per-operation
StateItemmetadata in the async client'sexecute_state_transaction, mirroring the sync client (#791). Without, per-op metadata e.g.outbox.projectionfor the transactional outbox is silently dropped, so both operations get published and the projection payload overwrites the state value.Issue reference
#1131
Checklist
Please make sure you've completed the relevant tasks for this PR, out of the following list: