From dbb80421d86cc1737f14e5183e859013c820d4fa Mon Sep 17 00:00:00 2001 From: Alex Mazzeo Date: Mon, 27 Apr 2026 18:16:20 -0700 Subject: [PATCH 1/5] Use business IDs in nexus samples --- src/NexusCancellation/Handler/HelloService.cs | 13 ++++++++----- src/NexusContextPropagation/Handler/HelloService.cs | 13 ++++++++----- src/NexusMultiArg/Handler/HelloService.cs | 13 ++++++++----- src/NexusSimple/Handler/HelloService.cs | 13 ++++++++----- 4 files changed, 32 insertions(+), 20 deletions(-) diff --git a/src/NexusCancellation/Handler/HelloService.cs b/src/NexusCancellation/Handler/HelloService.cs index 69fbd1f..29f95f3 100644 --- a/src/NexusCancellation/Handler/HelloService.cs +++ b/src/NexusCancellation/Handler/HelloService.cs @@ -14,8 +14,11 @@ public class HelloService context.StartWorkflowAsync( (HelloHandlerWorkflow wf) => wf.RunAsync(input), // Workflow IDs should typically be business meaningful IDs and are used to - // dedupe workflow starts. For this example, we're using the request ID - // allocated by Temporal when the caller workflow schedules the operation, - // this ID is guaranteed to be stable across retries of this operation. - new() { Id = context.HandlerContext.RequestId })); -} \ No newline at end of file + // dedupe workflow starts. Use a business ID derived from the operation + // input instead of the Nexus request ID. The request ID is still available + // separately as an idempotency key for retries of the operation. + new() { Id = GetHelloWorkflowId(input) })); + + private static string GetHelloWorkflowId(IHelloService.HelloInput input) => + $"hello-{input.Language}-{input.Name.Trim().Replace(' ', '-')}"; +} diff --git a/src/NexusContextPropagation/Handler/HelloService.cs b/src/NexusContextPropagation/Handler/HelloService.cs index 413aa24..b0a57a9 100644 --- a/src/NexusContextPropagation/Handler/HelloService.cs +++ b/src/NexusContextPropagation/Handler/HelloService.cs @@ -19,9 +19,12 @@ public class HelloService return context.StartWorkflowAsync( (HelloHandlerWorkflow wf) => wf.RunAsync(input), // Workflow IDs should typically be business meaningful IDs and are used to - // dedupe workflow starts. For this example, we're using the request ID - // allocated by Temporal when the caller workflow schedules the operation, - // this ID is guaranteed to be stable across retries of this operation. - new() { Id = context.HandlerContext.RequestId }); + // dedupe workflow starts. Use a business ID derived from the operation + // input instead of the Nexus request ID. The request ID is still available + // separately as an idempotency key for retries of the operation. + new() { Id = GetHelloWorkflowId(input) }); }); -} \ No newline at end of file + + private static string GetHelloWorkflowId(IHelloService.HelloInput input) => + $"hello-{input.Language}-{input.Name.Trim().Replace(' ', '-')}"; +} diff --git a/src/NexusMultiArg/Handler/HelloService.cs b/src/NexusMultiArg/Handler/HelloService.cs index 42c8414..479384f 100644 --- a/src/NexusMultiArg/Handler/HelloService.cs +++ b/src/NexusMultiArg/Handler/HelloService.cs @@ -15,8 +15,11 @@ public class HelloService context.StartWorkflowAsync( (HelloHandlerWorkflow wf) => wf.RunAsync(input.Language, input.Name), // Workflow IDs should typically be business meaningful IDs and are used to - // dedupe workflow starts. For this example, we're using the request ID - // allocated by Temporal when the caller workflow schedules the operation, - // this ID is guaranteed to be stable across retries of this operation. - new() { Id = context.HandlerContext.RequestId })); -} \ No newline at end of file + // dedupe workflow starts. Use a business ID derived from the operation + // input instead of the Nexus request ID. The request ID is still available + // separately as an idempotency key for retries of the operation. + new() { Id = GetHelloWorkflowId(input) })); + + private static string GetHelloWorkflowId(IHelloService.HelloInput input) => + $"hello-{input.Language}-{input.Name.Trim().Replace(' ', '-')}"; +} diff --git a/src/NexusSimple/Handler/HelloService.cs b/src/NexusSimple/Handler/HelloService.cs index bc58cf8..d41e895 100644 --- a/src/NexusSimple/Handler/HelloService.cs +++ b/src/NexusSimple/Handler/HelloService.cs @@ -20,8 +20,11 @@ public class HelloService context.StartWorkflowAsync( (HelloHandlerWorkflow wf) => wf.RunAsync(input), // Workflow IDs should typically be business meaningful IDs and are used to - // dedupe workflow starts. For this example, we're using the request ID - // allocated by Temporal when the caller workflow schedules the operation, - // this ID is guaranteed to be stable across retries of this operation. - new() { Id = context.HandlerContext.RequestId })); -} \ No newline at end of file + // dedupe workflow starts. Use a business ID derived from the operation + // input instead of the Nexus request ID. The request ID is still available + // separately as an idempotency key for retries of the operation. + new() { Id = GetHelloWorkflowId(input) })); + + private static string GetHelloWorkflowId(IHelloService.HelloInput input) => + $"hello-{input.Language}-{input.Name.Trim().Replace(' ', '-')}"; +} From 0d741db527845df669c4c45ddaa3afc43b58f1b1 Mon Sep 17 00:00:00 2001 From: Alex Mazzeo Date: Mon, 27 Apr 2026 18:22:20 -0700 Subject: [PATCH 2/5] fix bad comments from codex --- src/NexusCancellation/Handler/HelloService.cs | 6 +++--- src/NexusContextPropagation/Handler/HelloService.cs | 6 +++--- src/NexusMultiArg/Handler/HelloService.cs | 6 +++--- src/NexusSimple/Handler/HelloService.cs | 6 +++--- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/NexusCancellation/Handler/HelloService.cs b/src/NexusCancellation/Handler/HelloService.cs index 29f95f3..2aa9219 100644 --- a/src/NexusCancellation/Handler/HelloService.cs +++ b/src/NexusCancellation/Handler/HelloService.cs @@ -14,9 +14,9 @@ public class HelloService context.StartWorkflowAsync( (HelloHandlerWorkflow wf) => wf.RunAsync(input), // Workflow IDs should typically be business meaningful IDs and are used to - // dedupe workflow starts. Use a business ID derived from the operation - // input instead of the Nexus request ID. The request ID is still available - // separately as an idempotency key for retries of the operation. + // dedupe workflow starts. For this example, use a business ID derived from + // the greeting input so repeated operations for the same name and language + // resolve to the same workflow. new() { Id = GetHelloWorkflowId(input) })); private static string GetHelloWorkflowId(IHelloService.HelloInput input) => diff --git a/src/NexusContextPropagation/Handler/HelloService.cs b/src/NexusContextPropagation/Handler/HelloService.cs index b0a57a9..d4e9526 100644 --- a/src/NexusContextPropagation/Handler/HelloService.cs +++ b/src/NexusContextPropagation/Handler/HelloService.cs @@ -19,9 +19,9 @@ public class HelloService return context.StartWorkflowAsync( (HelloHandlerWorkflow wf) => wf.RunAsync(input), // Workflow IDs should typically be business meaningful IDs and are used to - // dedupe workflow starts. Use a business ID derived from the operation - // input instead of the Nexus request ID. The request ID is still available - // separately as an idempotency key for retries of the operation. + // dedupe workflow starts. For this example, use a business ID derived from + // the greeting input so repeated operations for the same name and language + // resolve to the same workflow. new() { Id = GetHelloWorkflowId(input) }); }); diff --git a/src/NexusMultiArg/Handler/HelloService.cs b/src/NexusMultiArg/Handler/HelloService.cs index 479384f..1d98a45 100644 --- a/src/NexusMultiArg/Handler/HelloService.cs +++ b/src/NexusMultiArg/Handler/HelloService.cs @@ -15,9 +15,9 @@ public class HelloService context.StartWorkflowAsync( (HelloHandlerWorkflow wf) => wf.RunAsync(input.Language, input.Name), // Workflow IDs should typically be business meaningful IDs and are used to - // dedupe workflow starts. Use a business ID derived from the operation - // input instead of the Nexus request ID. The request ID is still available - // separately as an idempotency key for retries of the operation. + // dedupe workflow starts. For this example, use a business ID derived from + // the greeting input so repeated operations for the same name and language + // resolve to the same workflow. new() { Id = GetHelloWorkflowId(input) })); private static string GetHelloWorkflowId(IHelloService.HelloInput input) => diff --git a/src/NexusSimple/Handler/HelloService.cs b/src/NexusSimple/Handler/HelloService.cs index d41e895..c518b5a 100644 --- a/src/NexusSimple/Handler/HelloService.cs +++ b/src/NexusSimple/Handler/HelloService.cs @@ -20,9 +20,9 @@ public class HelloService context.StartWorkflowAsync( (HelloHandlerWorkflow wf) => wf.RunAsync(input), // Workflow IDs should typically be business meaningful IDs and are used to - // dedupe workflow starts. Use a business ID derived from the operation - // input instead of the Nexus request ID. The request ID is still available - // separately as an idempotency key for retries of the operation. + // dedupe workflow starts. For this example, use a business ID derived from + // the greeting input so repeated operations for the same name and language + // resolve to the same workflow. new() { Id = GetHelloWorkflowId(input) })); private static string GetHelloWorkflowId(IHelloService.HelloInput input) => From 5bae4a52a7281725ff60a9fba9f6562f88062dd8 Mon Sep 17 00:00:00 2001 From: Alex Mazzeo Date: Mon, 18 May 2026 11:26:18 -0700 Subject: [PATCH 3/5] remove sanitization of workflow ID --- src/NexusCancellation/Handler/HelloService.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/NexusCancellation/Handler/HelloService.cs b/src/NexusCancellation/Handler/HelloService.cs index 2aa9219..90e53b2 100644 --- a/src/NexusCancellation/Handler/HelloService.cs +++ b/src/NexusCancellation/Handler/HelloService.cs @@ -19,6 +19,8 @@ public class HelloService // resolve to the same workflow. new() { Id = GetHelloWorkflowId(input) })); + + // Create a business meaningful ID derived from the operation input. private static string GetHelloWorkflowId(IHelloService.HelloInput input) => - $"hello-{input.Language}-{input.Name.Trim().Replace(' ', '-')}"; + $"hello-{input.Language}-{input.Name}"; } From 9cddf91b12a7db2eaee06f0530f12d307ca2d15e Mon Sep 17 00:00:00 2001 From: Alex Mazzeo Date: Mon, 18 May 2026 11:28:23 -0700 Subject: [PATCH 4/5] Address double line error --- src/NexusCancellation/Handler/HelloService.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/src/NexusCancellation/Handler/HelloService.cs b/src/NexusCancellation/Handler/HelloService.cs index 90e53b2..ae81188 100644 --- a/src/NexusCancellation/Handler/HelloService.cs +++ b/src/NexusCancellation/Handler/HelloService.cs @@ -19,7 +19,6 @@ public class HelloService // resolve to the same workflow. new() { Id = GetHelloWorkflowId(input) })); - // Create a business meaningful ID derived from the operation input. private static string GetHelloWorkflowId(IHelloService.HelloInput input) => $"hello-{input.Language}-{input.Name}"; From 7d2bb9159853e38b97e294f9863a508905349da9 Mon Sep 17 00:00:00 2001 From: Alex Mazzeo Date: Mon, 18 May 2026 11:36:05 -0700 Subject: [PATCH 5/5] Update remaining nexus samples to remove unnecessary sanitization --- src/NexusContextPropagation/Handler/HelloService.cs | 2 +- src/NexusMultiArg/Handler/HelloService.cs | 2 +- src/NexusSimple/Handler/HelloService.cs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/NexusContextPropagation/Handler/HelloService.cs b/src/NexusContextPropagation/Handler/HelloService.cs index d4e9526..1ad9ca3 100644 --- a/src/NexusContextPropagation/Handler/HelloService.cs +++ b/src/NexusContextPropagation/Handler/HelloService.cs @@ -26,5 +26,5 @@ public class HelloService }); private static string GetHelloWorkflowId(IHelloService.HelloInput input) => - $"hello-{input.Language}-{input.Name.Trim().Replace(' ', '-')}"; + $"hello-{input.Language}-{input.Name}"; } diff --git a/src/NexusMultiArg/Handler/HelloService.cs b/src/NexusMultiArg/Handler/HelloService.cs index 1d98a45..aff04f8 100644 --- a/src/NexusMultiArg/Handler/HelloService.cs +++ b/src/NexusMultiArg/Handler/HelloService.cs @@ -21,5 +21,5 @@ public class HelloService new() { Id = GetHelloWorkflowId(input) })); private static string GetHelloWorkflowId(IHelloService.HelloInput input) => - $"hello-{input.Language}-{input.Name.Trim().Replace(' ', '-')}"; + $"hello-{input.Language}-{input.Name}"; } diff --git a/src/NexusSimple/Handler/HelloService.cs b/src/NexusSimple/Handler/HelloService.cs index c518b5a..f597ed3 100644 --- a/src/NexusSimple/Handler/HelloService.cs +++ b/src/NexusSimple/Handler/HelloService.cs @@ -26,5 +26,5 @@ public class HelloService new() { Id = GetHelloWorkflowId(input) })); private static string GetHelloWorkflowId(IHelloService.HelloInput input) => - $"hello-{input.Language}-{input.Name.Trim().Replace(' ', '-')}"; + $"hello-{input.Language}-{input.Name}"; }