From 089bbea710697e49fdec193489129877d191288a Mon Sep 17 00:00:00 2001 From: pdoerner <122412190+pdoerner@users.noreply.github.com> Date: Thu, 3 Oct 2024 09:59:26 -0700 Subject: [PATCH] Set CanceledFailureInfo for all canceled Nexus outcomes (#2253) --- .../internal/testservice/TestWorkflowService.java | 10 +++++++--- .../testserver/functional/NexusWorkflowTest.java | 7 ++++--- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/temporal-test-server/src/main/java/io/temporal/internal/testservice/TestWorkflowService.java b/temporal-test-server/src/main/java/io/temporal/internal/testservice/TestWorkflowService.java index 3c908499b..f2a016bed 100644 --- a/temporal-test-server/src/main/java/io/temporal/internal/testservice/TestWorkflowService.java +++ b/temporal-test-server/src/main/java/io/temporal/internal/testservice/TestWorkflowService.java @@ -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()) { @@ -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; diff --git a/temporal-test-server/src/test/java/io/temporal/testserver/functional/NexusWorkflowTest.java b/temporal-test-server/src/test/java/io/temporal/testserver/functional/NexusWorkflowTest.java index 4af71fd88..eaafaed60 100644 --- a/temporal-test-server/src/test/java/io/temporal/testserver/functional/NexusWorkflowTest.java +++ b/temporal-test-server/src/test/java/io/temporal/testserver/functional/NexusWorkflowTest.java @@ -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 { @@ -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 {