Add support for setting ActivityID - #3044
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 👍 / 👎.
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 the core activity scheduling and replay path; incorrect or non-deterministic activity IDs can break workflow replay or violate uniqueness among open activities.
Overview
Adds experimental per-call control over Activity and Local Activity scheduling via
ActivityInvocationOptions, chieflysetActivityIdfor deduplication and async completion scenarios.Workflow code can use
Workflow.executeActivity/executeActivityAsync(typed method references) orActivityStuboverloads that takeActivityInvocationOptions. OptionalsetActivityOptionsreplaces stub options for that single remote activity only; local activities reject that field. When no ID is set, behavior stays the same (server/SDK-generated IDs).Internally,
ActivityInvocationInternaluses a thread-local so one options object applies to exactly one stub call inside the lambda. The optional ID flows throughWorkflowOutboundCallsInterceptor.ActivityInput/LocalActivityInputintoSyncWorkflowContext, which setsactivity_idon schedule commands and preserves it across local-activity retries. Package docs and integration tests cover history, concurrency, option overrides, and replay when the explicit ID is stable vs changed.Reviewed by Cursor Bugbot for commit 01d2725. Bugbot is set up for automated code reviews on this repo. Configure here.