Skip to content

Commit

Permalink
Set CanceledFailureInfo for all canceled Nexus outcomes (temporalio#2253
Browse files Browse the repository at this point in the history
)
  • Loading branch information
pdoerner authored Oct 3, 2024
1 parent 156f4f1 commit 089bbea
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,12 @@ public void respondNexusTaskCompleted(
}

if (request.getResponse().hasCancelOperation()) {
mutableState.cancelNexusOperation(tt.getOperationRef(), null);
Failure canceled =
Failure.newBuilder()
.setMessage("operation canceled")
.setCanceledFailureInfo(CanceledFailureInfo.getDefaultInstance())
.build();
mutableState.cancelNexusOperation(tt.getOperationRef(), canceled);
} else if (request.getResponse().hasStartOperation()) {
StartOperationResponse startResp = request.getResponse().getStartOperation();
if (startResp.hasOperationError()) {
Expand Down Expand Up @@ -913,8 +918,7 @@ public void completeNexusOperation(NexusOperationRef ref, HistoryEvent completio
Failure canceled =
Failure.newBuilder()
.setMessage("operation canceled")
.setApplicationFailureInfo(
ApplicationFailureInfo.newBuilder().setNonRetryable(true))
.setCanceledFailureInfo(CanceledFailureInfo.getDefaultInstance())
.build();
target.cancelNexusOperation(ref, canceled);
break;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -287,8 +287,7 @@ public void testNexusOperationAsyncHandlerCanceled() {
Assert.assertEquals("nexus operation completed unsuccessfully", failure.getMessage());
io.temporal.api.failure.v1.Failure cause = failure.getCause();
Assert.assertEquals("operation canceled", cause.getMessage());
Assert.assertNotNull(cause.getApplicationFailureInfo());
Assert.assertTrue(cause.getApplicationFailureInfo().getNonRetryable());
Assert.assertTrue(cause.hasCanceledFailureInfo());
} catch (Exception e) {
Assert.fail(e.getMessage());
} finally {
Expand Down Expand Up @@ -529,7 +528,9 @@ public void testNexusOperationCancellation() {
events.get(0).getNexusOperationCanceledEventAttributes().getFailure();
assertOperationFailureInfo(operationId, failure.getNexusOperationExecutionFailureInfo());
Assert.assertEquals("nexus operation completed unsuccessfully", failure.getMessage());
Assert.assertFalse(failure.hasCause());
io.temporal.api.failure.v1.Failure cause = failure.getCause();
Assert.assertEquals("operation canceled", cause.getMessage());
Assert.assertTrue(cause.hasCanceledFailureInfo());
} catch (Exception e) {
Assert.fail(e.getMessage());
} finally {
Expand Down

0 comments on commit 089bbea

Please sign in to comment.