Skip to content

Pass per-operation StateItem metadata in async execute_state_transaction#1132

Merged
acroca merged 1 commit into
dapr:mainfrom
LilDojd:fix/aio-grpc-client-metadata
Jul 9, 2026
Merged

Pass per-operation StateItem metadata in async execute_state_transaction#1132
acroca merged 1 commit into
dapr:mainfrom
LilDojd:fix/aio-grpc-client-metadata

Conversation

@LilDojd

@LilDojd LilDojd commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Description

Pass per-operation StateItem metadata in the async client's execute_state_transaction, mirroring the sync client (#791). Without, per-op metadata e.g. outbox.projection for 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:

  • Code compiles correctly
  • Created/updated tests
  • Extended the documentation

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
@LilDojd LilDojd requested review from a team as code owners July 8, 2026 13:05
@acroca acroca requested a review from Copilot July 9, 2026 06:06

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 metadata when building StateItem in dapr.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.

@acroca

acroca commented Jul 9, 2026

Copy link
Copy Markdown
Member

@LilDojd Thanks for the contribution!

@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 82.13%. Comparing base (bffb749) to head (2d49ef1).
⚠️ Report is 179 commits behind head on main.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@acroca acroca added this pull request to the merge queue Jul 9, 2026
Merged via the queue into dapr:main with commit 2f0ab79 Jul 9, 2026
17 of 19 checks passed
acroca pushed a commit that referenced this pull request Jul 9, 2026
…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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants