-
Couldn't load subscription status.
- Fork 48
Open
Labels
team/server-at-scaleDescribes the Octopus Deploy team called Server At ScaleDescribes the Octopus Deploy team called Server At Scale
Description
Team
- I've assigned a team label to this issue
What happened?
When passing null to an asynchronous service method accepting a Nullable<T> parameter, Halibut will not consider it a match and fails with the following exception:
Halibut.Exceptions.AmbiguousMethodMatchHalibutClientException : Could not decide which candidate to call out of the following methods:
- System.Threading.Tasks.Task`1[System.Int32] IncrementAsync(System.Threading.CancellationToken)
- System.Threading.Tasks.Task`1[System.Int32] IncrementAsync(System.Nullable`1[System.Int32], System.Threading.CancellationToken)
The request arguments were:
<null>
Reproduction
Define an async service method like this:
public interface ICountingService
{
public int Increment(int? number);
}
public interface IAsyncCountingService
{
public Task<int> IncrementAsync(int? number, CancellationToken cancellationToken);
}And invoke it like this:
[Test]
public async Task AsyncInvokeWithNullableParamsOnAsyncService()
{
var serviceFactory = new ServiceFactoryBuilder()
.WithConventionVerificationDisabled()
.WithService<ICountingService, IAsyncCountingService>(() => new AsyncCountingService())
.Build();
var sut = new ServiceInvoker(serviceFactory);
var request = new RequestMessage()
{
ServiceName = nameof(ICountingService),
MethodName = nameof(ICountingService.Increment),
Params = new object[] { null! },
};
var response = await sut.InvokeAsync(request);
response.Result.Should().Be(1);
}Error and Stacktrace
Halibut.Exceptions.AmbiguousMethodMatchHalibutClientException : Could not decide which candidate to call out of the following methods:
- System.Threading.Tasks.Task`1[System.Int32] IncrementAsync(System.Threading.CancellationToken)
- System.Threading.Tasks.Task`1[System.Int32] IncrementAsync(System.Nullable`1[System.Int32], System.Threading.CancellationToken)
The request arguments were:
<null>More Information
I have written a test and patched the bug, will submit a PR ASAP.
Workaround
No response
Discolai
Metadata
Metadata
Assignees
Labels
team/server-at-scaleDescribes the Octopus Deploy team called Server At ScaleDescribes the Octopus Deploy team called Server At Scale