Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unintentional input unwrapping for OOP workers #2656

Merged
merged 4 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Comment on lines -132 to +135
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

retroactive bug find: this change in the if-condition affects the "legacy" OOProc SDKs - JS, PowerShell, Python. In those cases, the destinationType is string, so we should have entered this if-statement, but we no longer do.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ironically, the comment here describes precisely how this if statement was supposed to be used, but we missed that during review.

{
return serializedValue;
}
Expand Down
Loading