Skip to content

Expose a replay-safe new_guid on WorkflowContext - #1202

Open
magic-peach wants to merge 1 commit into
dapr:mainfrom
magic-peach:feat/workflow-context-new-guid
Open

Expose a replay-safe new_guid on WorkflowContext#1202
magic-peach wants to merge 1 commit into
dapr:mainfrom
magic-peach:feat/workflow-context-new-guid

Conversation

@magic-peach

Copy link
Copy Markdown

Description

The underlying orchestration context already generates deterministic GUIDs internally (the worker itself uses this 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.

Issue reference

Please reference the issue this PR will close: #1188

Checklist

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

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>

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.

🟡 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

codecov Bot commented Sep 9, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 83.22%. Comparing base (e4ad181) to head (91d5012).

Files with missing lines Patch % Lines
dapr/ext/workflow/workflow_context.py 75.00% 1 Missing ⚠️
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.
📢 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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[WORKFLOW SDK FEATURE REQUEST] Implement "new_guid" on WorkflowContext

2 participants