Skip to content

Add support for workflow history propagation#1739

Open
siri-varma wants to merge 16 commits into
dapr:masterfrom
siri-varma:users/svegiraju/implement-workflow-2
Open

Add support for workflow history propagation#1739
siri-varma wants to merge 16 commits into
dapr:masterfrom
siri-varma:users/svegiraju/implement-workflow-2

Conversation

@siri-varma
Copy link
Copy Markdown
Contributor

Description

Please explain the changes you've made

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

@javier-aliaga
Copy link
Copy Markdown
Contributor

@siri-varma this PR #1738 will fix the CI and also uses the 1.18.0 rc version. I think you need it to test this PR

@siri-varma siri-varma force-pushed the users/svegiraju/implement-workflow-2 branch 3 times, most recently from a1c39f5 to 5d732f3 Compare May 18, 2026 14:39
siri-varma and others added 6 commits May 18, 2026 07:42
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
Signed-off-by: Siri Varma Vegiraju <s_vegiraju@apple.com>
Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
Signed-off-by: Siri Varma Vegiraju <s_vegiraju@apple.com>
Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
Signed-off-by: Siri Varma Vegiraju <s_vegiraju@apple.com>
Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
Signed-off-by: Siri Varma Vegiraju <s_vegiraju@apple.com>
Signed-off-by: Siri Varma Vegiraju <s_vegiraju@apple.com>
Signed-off-by: Siri Varma Vegiraju <s_vegiraju@apple.com>
@siri-varma siri-varma force-pushed the users/svegiraju/implement-workflow-2 branch from 5d732f3 to 66f5b53 Compare May 18, 2026 14:42
Siri Varma Vegiraju added 4 commits May 18, 2026 07:46
Signed-off-by: Siri Varma Vegiraju <s_vegiraju@apple.com>
Signed-off-by: Siri Varma Vegiraju <s_vegiraju@apple.com>
Signed-off-by: Siri Varma Vegiraju <s_vegiraju@apple.com>
Signed-off-by: Siri Varma Vegiraju <s_vegiraju@apple.com>
@siri-varma siri-varma marked this pull request as ready for review May 18, 2026 16:08
@siri-varma siri-varma requested review from a team as code owners May 18, 2026 16:08
@siri-varma
Copy link
Copy Markdown
Contributor Author

@javier-aliaga @dapr/maintainers-java-sdk Ready for reviews

Comment thread durabletask-client/src/main/java/io/dapr/durabletask/HistoryPropagationScope.java Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

Comment thread durabletask-client/src/main/java/io/dapr/durabletask/PropagatedHistory.java Outdated
Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
Signed-off-by: Siri Varma Vegiraju <s_vegiraju@apple.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

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 36 out of 36 changed files in this pull request and generated 3 comments.

Comments suppressed due to low confidence (1)

durabletask-client/src/main/java/io/dapr/durabletask/PropagatedHistoryChunk.java:52

  • This implementation only exposes parsed HistoryEvent objects via getEvents(). If downstream consumers are expected to perform chain-of-custody/signature verification on the original signed bytes (as implied by the Javadoc), there is no way to access the raw event bytes after parsing. Consider either exposing the raw event payloads on PropagatedHistoryChunk (e.g., as List<ByteString>/byte[]) or adjusting the documentation to remove the verification claim.
  static PropagatedHistoryChunk fromProto(HistoryEvents.PropagatedHistoryChunk proto) {
    List<HistoryEvents.HistoryEvent> parsed = new ArrayList<>(proto.getRawEventsCount());
    for (int i = 0; i < proto.getRawEventsCount(); i++) {
      try {
        parsed.add(HistoryEvents.HistoryEvent.parseFrom(proto.getRawEvents(i)));
      } catch (InvalidProtocolBufferException e) {
        throw new IllegalArgumentException(
            "Failed to parse raw event " + i + " in chunk for app " + proto.getAppId(), e);
      }

Comment thread durabletask-client/src/main/java/io/dapr/durabletask/PropagatedHistoryChunk.java Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Signed-off-by: Siri Varma Vegiraju <siri.varma@outlook.com>
Comment on lines +145 to +147
PropagatedHistory parsed = propagatedHistory != null
? PropagatedHistory.fromProto(propagatedHistory) : null;
ContextImplTask context = new ContextImplTask(pastEvents, newEvents, parsed);
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.

Should we movePropagatedHistory.fromProto into the try/catch block so we can fail the context in case of exception?

@codecov
Copy link
Copy Markdown

codecov Bot commented May 19, 2026

Codecov Report

❌ Patch coverage is 94.11765% with 1 line in your changes missing coverage. Please review.
✅ Project coverage is 76.78%. Comparing base (89708ae) to head (5eb5664).

Files with missing lines Patch % Lines
...kflows/runtime/DefaultWorkflowActivityContext.java 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff            @@
##             master    #1739   +/-   ##
=========================================
  Coverage     76.77%   76.78%           
- Complexity     2259     2266    +7     
=========================================
  Files           241      241           
  Lines          7066     7076   +10     
  Branches        740      740           
=========================================
+ Hits           5425     5433    +8     
- Misses         1277     1280    +3     
+ Partials        364      363    -1     

☔ View full report in Codecov by Sentry.
📢 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.

}

PropagatedHistory parsed = propagatedHistory != null
? PropagatedHistory.fromProto(propagatedHistory) : null;
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.

Can we have a custom exception here so it is clear that the propagated history is broken?

Copy link
Copy Markdown
Contributor

@cicoyle cicoyle left a comment

Choose a reason for hiding this comment

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

This is a great start 🎉 few things from me for parity and user experience

PropagatedHistory history = historyOpt.get();
logger.info("App2 received history (scope={}, chunks={}, apps={})",
history.getScope(), history.getWorkflows().size(), history.getAppIDs());
for (PropagatedHistoryChunk chunk : history.getWorkflows()) {
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.

I was thinking for chunks to not be user facing. They shouldn't need to know about the internal chunking mechanism. Can we rename this to WorkflowResult or similar and have a wrapper?
From there the following is exposed for end user consumption:

Image

history.getScope(), history.getWorkflows().size(), history.getAppIDs());
for (PropagatedHistoryChunk chunk : history.getWorkflows()) {
logger.info(" chunk: app={} workflow={} instance={} events={}",
chunk.getAppId(), chunk.getWorkflowName(), chunk.getInstanceId(),
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.

Can we add getActivityByName and getActivitiesByName? The goal was to use the chunks under the hood and expose this functionality using the history chunks. For ex, in the go-sdk we have:

...
merchantWf, err := history.GetWorkflowByName("MerchantCheckout")
card, err := processPaymentWf.GetActivityByName("ValidateCard")
...
Image

Where a user can directly see the status of it with these exposed/user facing fields:

type ActivityResult struct {
    Name      string
    Started   bool
    Completed bool
    Failed    bool
    Input     *wrapperspb.StringValue
    Output    *wrapperspb.StringValue
    Error     *protos.TaskFailureDetails
}
Image

ActivityResult holds the status and data of a named activity.

String input = ctx.getInput(String.class);
logger.info("=== App2 audit activity invoked with input: {} ===", input);

Optional<PropagatedHistory> historyOpt = ctx.getPropagatedHistory();
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.

Can we also add getChildWorkflowByName and getChildWorkflowsByName on the WorkflowResult?

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.

4 participants