diff --git a/release_notes.md b/release_notes.md index 6f5e0c462..5d4942399 100644 --- a/release_notes.md +++ b/release_notes.md @@ -16,9 +16,9 @@ ### Bug Fixes -- Fix failed orchestration/entities not showing up as function invocation failures. +- Fix issue where json token input (not a json object) was unwrapped before sending to an out-of-proc worker. This could then lead to deserialization issues as the wrapping quotes were missing. (Applies to dotnet-isolated and java only) +- Fix failed orchestration/entities not showing up as function invocation failures. (Applies to dotnet-isolated and java only) ### Breaking Changes ### Dependency Updates - diff --git a/src/WebJobs.Extensions.DurableTask/ContextImplementations/DurableActivityContext.cs b/src/WebJobs.Extensions.DurableTask/ContextImplementations/DurableActivityContext.cs index f0812bc64..560fedf48 100644 --- a/src/WebJobs.Extensions.DurableTask/ContextImplementations/DurableActivityContext.cs +++ b/src/WebJobs.Extensions.DurableTask/ContextImplementations/DurableActivityContext.cs @@ -20,6 +20,7 @@ internal class DurableActivityContext : IDurableActivityContext, private readonly string instanceId; private readonly MessagePayloadDataConverter messageDataConverter; private readonly bool inputsAreArrays; + private readonly bool rawInput; private JToken parsedJsonInput; private string serializedOutput; @@ -35,6 +36,9 @@ internal DurableActivityContext(DurableTaskExtension config, string instanceId, this.inputsAreArrays = config.OutOfProcProtocol == OutOfProcOrchestrationProtocol.OrchestratorShim || config.PlatformInformationService.GetWorkerRuntimeType() == WorkerRuntimeType.DotNetIsolated; + + // Do not manipulate JSON input when using middleware passthrough. + this.rawInput = config.OutOfProcProtocol == OutOfProcOrchestrationProtocol.MiddlewarePassthrough; } /// @@ -116,8 +120,7 @@ internal object GetInput(Type destinationType) return null; } - var value = jToken as JValue; - if (value != null) + if (!this.rawInput && jToken is JValue value) { return value.ToObject(destinationType); } @@ -129,7 +132,7 @@ internal object GetInput(Type destinationType) // MessagePayloadDataConverter to throw an exception. This is a workaround for that case. All other // inputs with destination System.String (in-proc: JSON and not JSON; out-of-proc: not-JSON) inputs with // destination System.String should cast to JValues and be handled above.) - if (destinationType.Equals(typeof(string))) + if (this.rawInput) { return serializedValue; }