Skip to content

Commit bc5ab1d

Browse files
When parsing operation token allow a zero version (#2591)
1 parent ca3a27a commit bc5ab1d

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

temporal-sdk/src/main/java/io/temporal/internal/nexus/OperationTokenUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ public static WorkflowRunOperationToken loadWorkflowRunOperationToken(String ope
3131
throw new IllegalArgumentException(
3232
"Invalid workflow run token: incorrect operation token type: " + token.getType());
3333
}
34-
if (token.getVersion() != null) {
34+
if (token.getVersion() != null && token.getVersion() != 0) {
3535
throw new IllegalArgumentException("Invalid workflow run token: unexpected version field");
3636
}
3737
if (Strings.isNullOrEmpty(token.getWorkflowId())) {

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

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,20 @@ public void loadWorkflowIdFromOperationToken() {
8080
encoder.encodeToString(json.getBytes())));
8181
}
8282

83+
@Test
84+
public void loadWorkflowIdFromGoOperationToken() {
85+
// This is a token generated by the Go SDK, use this to test compatibility
86+
// across SDKs.
87+
String goOperationToken = "eyJ2IjowLCJ0IjoxLCJucyI6Im5zIiwid2lkIjoidyJ9";
88+
89+
WorkflowRunOperationToken token =
90+
OperationTokenUtil.loadWorkflowRunOperationToken(goOperationToken);
91+
Assert.assertEquals("w", token.getWorkflowId());
92+
Assert.assertEquals("ns", token.getNamespace());
93+
Assert.assertEquals(Integer.valueOf(0), token.getVersion());
94+
Assert.assertEquals(OperationTokenType.WORKFLOW_RUN, token.getType());
95+
}
96+
8397
@Test
8498
public void loadWorkflowIdFromBadOperationToken() {
8599
// Bad token, empty json

0 commit comments

Comments
 (0)