Skip to content

Commit

Permalink
Fix unintentional input unwrapping for OOP workers (#2656)
Browse files Browse the repository at this point in the history
* Fix unintentional input unwrapping for OOP workers

* Update release notes

* Refine fix to only apply to dotnet-isolated and java
  • Loading branch information
jviau authored Nov 9, 2023
1 parent 391486a commit f02cdd6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
4 changes: 2 additions & 2 deletions release_notes.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

/// <inheritdoc />
Expand Down Expand Up @@ -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);
}
Expand All @@ -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;
}
Expand Down

0 comments on commit f02cdd6

Please sign in to comment.