Skip to content

feat: throw WorkflowInstanceAlreadyExistsException when scheduling a workflow with an active instance ID#1782

Open
javier-aliaga wants to merge 3 commits into
dapr:masterfrom
javier-aliaga:feat/typed-exception-workflow-instance-exists
Open

feat: throw WorkflowInstanceAlreadyExistsException when scheduling a workflow with an active instance ID#1782
javier-aliaga wants to merge 3 commits into
dapr:masterfrom
javier-aliaga:feat/typed-exception-workflow-instance-exists

Conversation

@javier-aliaga

Copy link
Copy Markdown
Contributor

Description

related to dapr/dapr#10153

Issue reference

We strive to have all PR being opened based on an issue, where the problem or feature have been discussed prior to implementation.

Please reference the issue this PR will close: #[issue number]

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

…workflow with an active instance ID

Signed-off-by: Javier Aliaga <javier@diagrid.io>
@javier-aliaga javier-aliaga requested review from a team as code owners July 6, 2026 15:08
@javier-aliaga javier-aliaga requested review from Copilot and removed request for a team July 6, 2026 15:08

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

Adds a dedicated client-side exception for duplicate active workflow instance IDs and wires the scheduling APIs to translate the runtime/sidecar “already exists” signal into that exception (including a legacy-runtime fallback), with tests covering the new behavior.

Changes:

  • Introduces WorkflowInstanceAlreadyExistsException as a first-class client exception carrying the conflicting instance ID (when known).
  • Wraps scheduleNewWorkflow* overloads in DaprWorkflowClient to translate gRPC ALREADY_EXISTS (and legacy UNKNOWN+message cases) into the new exception.
  • Adds unit tests validating the translation and that unrelated gRPC errors are rethrown.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.

File Description
sdk-workflows/src/main/java/io/dapr/workflows/client/DaprWorkflowClient.java Maps specific gRPC failures from scheduling calls into WorkflowInstanceAlreadyExistsException.
sdk-workflows/src/main/java/io/dapr/workflows/client/WorkflowInstanceAlreadyExistsException.java Adds a new exception type that exposes the conflicting workflow instance ID.
sdk-workflows/src/test/java/io/dapr/workflows/client/DaprWorkflowClientTest.java Adds tests for duplicate-instance translation (including legacy-runtime behavior) and rethrow behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Annotate nullable instanceId field, restrict the legacy fallback to
UNKNOWN status with the runtime's specific collision message, and
assert instance ID propagation into NewOrchestrationInstanceOptions.

Signed-off-by: Javier Aliaga <javier@diagrid.io>

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

Copilot reviewed 3 out of 3 changed files in this pull request and generated no new comments.

@codecov

codecov Bot commented Jul 6, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.96%. Comparing base (79d9812) to head (610c55e).

Files with missing lines Patch % Lines
...client/WorkflowInstanceAlreadyExistsException.java 66.66% 1 Missing and 1 partial ⚠️
...a/io/dapr/workflows/client/DaprWorkflowClient.java 93.33% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##             master    #1782      +/-   ##
============================================
+ Coverage     76.89%   76.96%   +0.06%     
- Complexity     2307     2319      +12     
============================================
  Files           244      245       +1     
  Lines          7163     7180      +17     
  Branches        753      756       +3     
============================================
+ Hits           5508     5526      +18     
  Misses         1288     1288              
+ Partials        367      366       -1     

☔ 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.

2 participants