Add support for setting ActivityID - #3044
Quinn-With-Two-Ns wants to merge 1 commit into
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 01d272538a
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| try { | ||
| invocationFunction.apply(); | ||
| return state.getResult(); |
There was a problem hiding this comment.
Preserve transformations performed by activity lambdas
When the supplied function is a lambda that transforms the activity result, such as () -> activities.getNumber() + 1, the proxy captures the underlying Activity Promise but returns a default value to the lambda; this call then discards the lambda's computed result and returns the captured promise unchecked. Consequently the example resolves to the raw Activity value rather than the incremented value, and lambdas that dereference object results can throw NullPointerException. Either preserve the function's result semantics or reject anything other than a direct Activity invocation.
Useful? React with 👍 / 👎.
|
Been running this cherry-picked on 1.38.0 in our dev environment for a few weeks. Same use case as #86: setting the activityId to a domain id lets an external consumer complete a doNotCompleteOnReturn activity with just workflowId + activityId, no task token to pass around. On the replay concern from review: the workflow that uses it is covered by a golden-history replay test, and we haven't seen any non-determinism from setting the activityId. Any chance this lands in a release soon? Would let us drop the custom build. |
01d2725 to
ad051e8
Compare
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.
Reviewed by Cursor Bugbot for commit ad051e8. Configure here.
ad051e8 to
328fab3
Compare

What was changed
Add support for setting ActivityID
Why?
Add support for setting
ActivityID, for manual completion or deduplication.Checklist
Closes Support passing activityId to an activity invocation #86
How was this tested:
Note
Medium Risk
Changes activity scheduling and interceptor inputs on the workflow execution path; incorrect ID handling could break replay determinism or duplicate open activities, though defaults preserve prior behavior.
Overview
Adds per-invocation Activity options so workflows can supply an optional Activity ID when scheduling remote or local activities (for deduplication, manual completion, and stable identity), without putting that ID on reusable stubs.
Introduces experimental
ActivityInvocationOptionsand manyWorkflow.executeActivity/executeActivityAsyncoverloads (sync, async, void, typed method references). UntypedActivityStubgains matchingexecute/executeAsyncoverloads.ActivityInvocationInternaluses a thread-local to apply options to exactly one stub call inside the wrapped lambda.The optional ID is carried through
WorkflowOutboundCallsInterceptor.ActivityInput/LocalActivityInputintoSyncWorkflowContext, which setsactivity_idon scheduled activity commands (and preserves it across local-activity retries). Existing call paths passnullso the SDK still generates IDs. Package docs and integration tests cover history, concurrency, generics, local activities, and replay when the explicit ID changes.Reviewed by Cursor Bugbot for commit 328fab3. Bugbot is set up for automated code reviews on this repo. Configure here.