Expose a replay-safe new_guid on WorkflowContext - #1202
Open
magic-peach wants to merge 1 commit into
Open
Conversation
The underlying orchestration context already generates deterministic GUIDs internally (used by the worker itself for task execution ids), but nothing on the public WorkflowContext exposed it to workflow authors, so anyone needing a stable id inside a workflow had to reach for uuid4 and break replay determinism. Adds new_guid as an abstract method on WorkflowContext and implements it on DaprWorkflowContext by delegating to the wrapped context, matching the .NET SDK's NewGuid. Signed-off-by: Akanksha Trehun <akankshatrehun@gmail.com>
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The implementation calls a method absent from the wrapped context’s declared type, causing mypy failure.
Once you've addressed the issues Copilot identified, you can request another Copilot review.
Pull request overview
Exposes replay-safe GUID generation to workflow authors through WorkflowContext.
Changes:
- Adds the abstract
new_guid()API. - Delegates GUID generation to the durable-task context.
- Tests the delegation behavior.
File summaries
| File | Description |
|---|---|
dapr/ext/workflow/workflow_context.py |
Defines the public replay-safe GUID API. |
dapr/ext/workflow/dapr_workflow_context.py |
Proxies GUID generation to the internal context. |
tests/ext/workflow/test_dapr_workflow_context.py |
Tests the new proxy method. |
Review details
- Files reviewed: 3/3 changed files
- Comments generated: 1
- Review effort level: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
| self.__obj.set_custom_status(custom_status) | ||
|
|
||
| def new_guid(self) -> UUID: | ||
| return self.__obj.new_guid() |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #1202 +/- ##
==========================================
+ Coverage 83.15% 83.22% +0.06%
==========================================
Files 123 123
Lines 10260 10267 +7
==========================================
+ Hits 8532 8545 +13
+ Misses 1728 1722 -6 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
The underlying orchestration context already generates deterministic GUIDs internally (the worker itself uses this for task execution ids), but nothing on the public
WorkflowContextexposed it to workflow authors, so anyone needing a stable id inside a workflow had to reach foruuid4and break replay determinism.Adds
new_guidas an abstract method onWorkflowContextand implements it onDaprWorkflowContextby delegating to the wrapped context, matching the .NET SDK'sNewGuid.Issue reference
Please reference the issue this PR will close: #1188
Checklist