Skip to content

Commit

Permalink
Fix handling of entity operation errors for isolated entities (#2752)
Browse files Browse the repository at this point in the history
* fix handling of entity operation errors when using out-of-proc middleware

* udpate release notes
  • Loading branch information
sebastianburckhardt authored Mar 5, 2024
1 parent 7f42ccf commit e568610
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 9 deletions.
1 change: 1 addition & 0 deletions release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

- Fix issue with isolated entities: custom deserialization was not working because IServices was not passed along (https://github.com/Azure/azure-functions-durable-extension/pull/2686)
- Fix issue with `string` activity input having extra quotes (https://github.com/Azure/azure-functions-durable-extension/pull/2708)
- Fix issue with out-of-proc entity operation errors: success/failure details of individual operations in a batch was not processed correctly (https://github.com/Azure/azure-functions-durable-extension/pull/2752)

### Breaking Changes

Expand Down
29 changes: 20 additions & 9 deletions src/WebJobs.Extensions.DurableTask/OutOfProcMiddleware.cs
Original file line number Diff line number Diff line change
Expand Up @@ -374,15 +374,27 @@ void SetErrorResult(FailureDetails failureDetails)
functionName.Name,
batchRequest.InstanceId,
functionResult.Exception.ToString(),
FunctionType.Orchestrator,
FunctionType.Entity,
isReplay: false);

SetErrorResult(new FailureDetails(
errorType: "FunctionInvocationFailed",
errorMessage: $"Invocation of function '{functionName}' failed with an exception.",
stackTrace: null,
innerFailure: new FailureDetails(functionResult.Exception),
isNonRetriable: true));
if (context.Result != null)
{
// Send the results of the entity batch execution back to the DTFx dispatch pipeline.
// This is important so we can propagate the individual failure details of each failed operation back to the
// calling orchestrator. Also, even though the function execution was reported as a failure,
// it may not be a "total failure", i.e. some of the operations in the batch may have succeeded and updated
// the entity state.
dispatchContext.SetProperty(context.Result);
}
else
{
SetErrorResult(new FailureDetails(
errorType: "FunctionInvocationFailed",
errorMessage: $"Invocation of function '{functionName}' failed with an exception.",
stackTrace: null,
innerFailure: new FailureDetails(functionResult.Exception),
isNonRetriable: true));
}

return;
}
Expand All @@ -399,8 +411,7 @@ void SetErrorResult(FailureDetails failureDetails)
FunctionType.Entity,
isReplay: false);

// Send the result of the orchestrator function to the DTFx dispatch pipeline.
// This allows us to bypass the default, in-process execution and process the given results immediately.
// Send the results of the entity batch execution back to the DTFx dispatch pipeline.
dispatchContext.SetProperty(batchResult);
}

Expand Down

0 comments on commit e568610

Please sign in to comment.