Skip to content

Commit 96ece13

Browse files
authored
Minor update fixes (#382)
1 parent 855047e commit 96ece13

File tree

2 files changed

+23
-10
lines changed

2 files changed

+23
-10
lines changed

src/Temporalio/Client/TemporalClient.Workflow.cs

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -253,19 +253,29 @@ public override async Task<WorkflowUpdateHandle<TUpdateResult>> StartUpdateWithS
253253
}
254254
catch (Exception e)
255255
{
256-
// If this is a multi-operation failure, set exception to the first non-aborted
256+
// If this is a multi-operation failure, set exception to the first present,
257+
// non-OK, non-aborted error
257258
if (e is RpcException rpcErr)
258259
{
259260
var status = rpcErr.GrpcStatus.Value;
260261
if (status != null && status.Details.Count == 1)
261262
{
262263
if (status.Details[0].TryUnpack(out Api.ErrorDetails.V1.MultiOperationExecutionFailure failure))
263264
{
264-
var nonAborted = failure.Statuses.FirstOrDefault(s => s.Details.Count == 0 ||
265-
!s.Details[0].Is(Api.Failure.V1.MultiOperationExecutionAborted.Descriptor));
266-
var grpcStatus = new GrpcStatus() { Code = nonAborted.Code, Message = nonAborted.Message };
267-
grpcStatus.Details.AddRange(nonAborted.Details);
268-
e = new RpcException(grpcStatus);
265+
var nonAborted = failure.Statuses.FirstOrDefault(s =>
266+
// Exists
267+
s != null &&
268+
// Not ok
269+
s.Code != (int)RpcException.StatusCode.OK &&
270+
// Not aborted
271+
(s.Details.Count == 0 ||
272+
!s.Details[0].Is(Api.Failure.V1.MultiOperationExecutionAborted.Descriptor)));
273+
if (nonAborted != null)
274+
{
275+
var grpcStatus = new GrpcStatus() { Code = nonAborted.Code, Message = nonAborted.Message };
276+
grpcStatus.Details.AddRange(nonAborted.Details);
277+
e = new RpcException(grpcStatus);
278+
}
269279
}
270280
}
271281
}
@@ -462,7 +472,7 @@ public async override Task<WorkflowUpdateHandle<TResult>> StartWorkflowUpdateAsy
462472
// If the requested stage is completed, wait for result, but discard the update
463473
// exception, that will come when _they_ call get result
464474
var handle = new WorkflowUpdateHandle<TResult>(
465-
Client, req.Request.Meta.UpdateId, input.Id, input.RunId)
475+
Client, req.Request.Meta.UpdateId, input.Id, resp.UpdateRef.WorkflowExecution.RunId)
466476
{ KnownOutcome = resp.Outcome };
467477
if (input.Options.WaitForStage == WorkflowUpdateStage.Completed)
468478
{

tests/Temporalio.Tests/Worker/WorkflowWorkerTests.cs

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3697,10 +3697,13 @@ await ExecuteWorkerAsync<UpdateWorkflow>(async worker =>
36973697
(UpdateWorkflow wf) => wf.RunAsync(),
36983698
new(id: $"workflow-{Guid.NewGuid()}", taskQueue: worker.Options.TaskQueue!));
36993699

3700-
// Make all possible overload calls via start then get response
3701-
await (await ((WorkflowHandle)handle).StartUpdateAsync(
3700+
// Make all possible overload calls via start then get response. For
3701+
// the first update we'll also confirm the run ID is set.
3702+
var updateHandle = await ((WorkflowHandle)handle).StartUpdateAsync(
37023703
(UpdateWorkflow wf) => wf.DoUpdateNoParamNoResponseAsync(),
3703-
new(WorkflowUpdateStage.Accepted))).GetResultAsync();
3704+
new(WorkflowUpdateStage.Accepted));
3705+
Assert.NotNull(updateHandle.WorkflowRunId);
3706+
await updateHandle.GetResultAsync();
37043707
Assert.Equal(
37053708
$"no-param-response: {handle.Id}",
37063709
await (await ((WorkflowHandle)handle).StartUpdateAsync(

0 commit comments

Comments
 (0)