Skip to content

Commit ee62ae7

Browse files
Address feedback
1 parent d1cd542 commit ee62ae7

2 files changed

Lines changed: 11 additions & 3 deletions

File tree

temporal-sdk/src/test/java/io/temporal/internal/nexus/WorkflowRunTokenTest.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,12 +119,20 @@ public void loadWorkflowIdFromBadOperationToken() {
119119
OperationTokenUtil.loadOperationToken(
120120
encoder.encodeToString(badTokenUnknownVersion.getBytes())));
121121

122-
// Bad token, unknown version
122+
// Bad token, unknown type (also has bad version, so loadOperationToken rejects on version)
123123
String badTokenUnknownType = "{\"t\":4,\"ns\":\"namespace\", \"wid\":\"workflowId\", \"v\":1}";
124124
Assert.assertThrows(
125125
IllegalArgumentException.class,
126126
() ->
127127
OperationTokenUtil.loadOperationToken(
128128
encoder.encodeToString(badTokenUnknownType.getBytes())));
129+
130+
// Bad token, unknown type with valid version — loadWorkflowRunOperationToken rejects on type
131+
String badTokenWrongType = "{\"t\":4,\"ns\":\"namespace\", \"wid\":\"workflowId\"}";
132+
Assert.assertThrows(
133+
IllegalArgumentException.class,
134+
() ->
135+
OperationTokenUtil.loadWorkflowRunOperationToken(
136+
encoder.encodeToString(badTokenWrongType.getBytes())));
129137
}
130138
}

temporal-sdk/src/test/java/io/temporal/workflow/nexus/AsyncWorkflowOperationTest.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ public String execute(String input) {
7575
// Result should only be completed if the operation is completed
7676
Assert.assertFalse("Result should not be completed", asyncOpHandle.getResult().isCompleted());
7777
OperationToken token =
78-
OperationTokenUtil.loadOperationToken(asyncExec.getOperationToken().get());
78+
OperationTokenUtil.loadWorkflowRunOperationToken(asyncExec.getOperationToken().get());
7979
Assert.assertTrue(token.getWorkflowId().startsWith(WORKFLOW_ID_PREFIX));
8080
// Unblock the operation
8181
Workflow.newExternalWorkflowStub(OperationWorkflow.class, token.getWorkflowId()).unblock();
@@ -87,7 +87,7 @@ public String execute(String input) {
8787
} catch (NexusOperationFailure e) {
8888
Assert.assertEquals("TestNexusService1", e.getService());
8989
Assert.assertEquals("operation", e.getOperation());
90-
token = OperationTokenUtil.loadOperationToken(e.getOperationToken());
90+
token = OperationTokenUtil.loadWorkflowRunOperationToken(e.getOperationToken());
9191
Assert.assertTrue(token.getWorkflowId().startsWith(WORKFLOW_ID_PREFIX));
9292
Assert.assertTrue(e.getCause() instanceof ApplicationFailure);
9393
ApplicationFailure applicationFailure = (ApplicationFailure) e.getCause();

0 commit comments

Comments
 (0)