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

Allow for an output binding value of an invocation result to be null #10698

Merged
merged 9 commits into from
Dec 19, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
2 changes: 2 additions & 0 deletions src/WebJobs.Script.Grpc/Channel/GrpcWorkerChannel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1068,6 +1068,8 @@ private async Task<object> GetBindingDataAsync(ParameterBinding binding, string
case ParameterBindingType.Data:
// Data was transferred by the worker using RPC
return binding.Data.ToObject();
case ParameterBindingType.None:
return null;
default:
throw new InvalidOperationException("Unknown ParameterBindingType");
satvu marked this conversation as resolved.
Show resolved Hide resolved
}
Expand Down
38 changes: 38 additions & 0 deletions test/WebJobs.Script.Tests/Workers/Rpc/GrpcWorkerChannelTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1546,6 +1546,20 @@ await TestHelpers.Await(() => GetInvocationLogs().Length == logLoop,
}
}

[Fact]
public async Task NullOutputBinding_DoesNotThrow()
satvu marked this conversation as resolved.
Show resolved Hide resolved
{
await CreateDefaultWorkerChannel();

var invocationId = Guid.NewGuid();
var resultSource = new TaskCompletionSource<ScriptInvocationResult>();
ScriptInvocationContext scriptInvocationContext = GetTestScriptInvocationContext(invocationId, resultSource, logger: _logger);
await _workerChannel.SendInvocationRequest(scriptInvocationContext);
await _workerChannel.InvokeResponse(BuildSuccessfulInvocationResponseWithNullOutputBinding(invocationId.ToString()));

Assert.Equal(TaskStatus.RanToCompletion, resultSource.Task.Status);
}

private static IEnumerable<FunctionMetadata> GetTestFunctionsList(string runtime, bool addWorkerProperties = false)
{
return GetTestFunctionsList(runtime, numberOfFunctions: 2, addWorkerProperties);
Expand Down Expand Up @@ -1690,6 +1704,30 @@ private static InvocationResponse BuildSuccessfulInvocationResponse(string invoc
};
}

private InvocationResponse BuildSuccessfulInvocationResponseWithNullOutputBinding(string invocationId)
{
StatusResult statusResult = new StatusResult()
{
Status = StatusResult.Types.Status.Success
};

ParameterBinding parameterBinding = new ParameterBinding()
{
Name = "output1",
Data = null
};

InvocationResponse invocationResponse = new InvocationResponse()
{
InvocationId = invocationId == null ? "TestInvocationId" : invocationId,
Result = statusResult
};

invocationResponse.OutputData.Add(parameterBinding);

return invocationResponse;
}

private static FunctionMetadata BuildFunctionMetadataForHttpTrigger(string name, string language = null)
{
var functionMetadata = new FunctionMetadata() { Name = name, Language = language };
Expand Down
Loading