Add Temporal Nexus Operation Handler#2842
Add Temporal Nexus Operation Handler#2842Quinn-With-Two-Ns wants to merge 3 commits intotemporalio:masterfrom
Conversation
| TestMultiArgWorkflowFunctions.TestNoArgsWorkflowProc.class, | ||
| wf -> { | ||
| wf.proc(); | ||
| return null; |
There was a problem hiding this comment.
@maciejdudko @GregoryTravis This is one issue I found with the approach, due to ambiguity in the lambda we have to return null here for workflows that don't return anything.
| IllegalArgumentException.class, | ||
| () -> | ||
| OperationTokenUtil.loadWorkflowRunOperationToken( | ||
| OperationTokenUtil.loadOperationToken( |
There was a problem hiding this comment.
Test no longer validates token type rejection
Medium Severity
The badTokenUnknownType test case switched from loadWorkflowRunOperationToken to loadOperationToken, which does not validate the token type. The test still passes, but only because the token coincidentally has "v":1 (rejected by version validation), not because t:4 is an unknown type. This means loadWorkflowRunOperationToken's type-rejection logic is no longer covered by any negative test case in this file, creating a silent coverage gap for a production code path used by WorkflowRunOperationImpl.cancel.
Reviewed by Cursor Bugbot for commit 6641b14. Configure here.
temporal-sdk/src/test/java/io/temporal/workflow/nexus/AsyncWorkflowOperationTest.java
Show resolved
Hide resolved
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
There are 2 total unresolved issues (including 1 from previous review).
Reviewed by Cursor Bugbot for commit 05a2002. Configure here.
| Assert.assertEquals("TestNexusService1", e.getService()); | ||
| Assert.assertEquals("operation", e.getOperation()); | ||
| token = OperationTokenUtil.loadWorkflowRunOperationToken(e.getOperationToken()); | ||
| token = OperationTokenUtil.loadOperationToken(e.getOperationToken()); |
There was a problem hiding this comment.
Test No Longer Validates Operation Token Type
Medium Severity
AsyncWorkflowOperationTest was changed to call loadOperationToken instead of loadWorkflowRunOperationToken when asserting the contents of the operation token returned by WorkflowRunOperation. loadOperationToken skips type validation, so the test no longer verifies that the token type is WORKFLOW_RUN. If a regression causes WorkflowRunOperation to produce a token with the wrong type, this test won't catch it. Similarly, WorkflowRunTokenTest.loadWorkflowIdFromBadOperationToken's badTokenUnknownType case was switched to loadOperationToken, so it now throws only due to v:1, not due to the unknown type — the type-rejection behavior is no longer tested at all.
Additional Locations (1)
Reviewed by Cursor Bugbot for commit 05a2002. Configure here.


Add TemporalOperationHandler for generic Nexus operations
Summary
Test plan
Note
Medium Risk
Adds new (experimental) public Nexus handler/client APIs and changes cancel dispatch/token parsing, which could affect how operation tokens are interpreted and how cancellations propagate.
Overview
Introduces an experimental generic Nexus integration via
TemporalOperationHandler, letting Nexus operation implementations return either sync results or async workflow-run tokens throughTemporalOperationResult, with default cancel behavior that cancels the underlying workflow based on the parsed operation token.Adds
TemporalNexusClienthelpers to start typed/untyped workflows from Nexus handlers, and extracts the common “start workflow + attach workflow links to the Nexus operation context” logic intoNexusStartWorkflowHelper, which is now reused byWorkflowRunOperationImpl.Generalizes operation-token handling by renaming
WorkflowRunOperationTokentoOperationTokenand updatingOperationTokenUtilto support loading tokens without asserting type (for cancel dispatch) while keeping a type-asserting workflow-run loader; updates and adds tests to cover the new handler paths (typed/untyped start, void workflows, sync result, and cancel behavior).Reviewed by Cursor Bugbot for commit 05a2002. Bugbot is set up for automated code reviews on this repo. Configure here.