Azure / Azure/azure-functions-dotnet-worker

Input binding fails for EventHub trigger when the binding type is List

Open
#1,382 1 comment 0 reactions 1 assignee Claimed by @brettsam View on GitHub
bug extensions: event-hubs team-issue
Dominant language
C#
Stars
466
Forks
215
Avg merge
3d 10h
Merged PRs (30d)
7

Description

Input binding fails💥 for EventHub trigger when the binding type is `List`! See the below 2 functions. Run1 works fine, Run2 fails because `inputs` is not populated and is `null`

```csharp
[Function("MyEventHubTriggerEnumerable")]
public void Run1([EventHubTrigger("samples-workitems", Connection = "Con")] IEnumerable inputs)
{
_logger.LogInformation($"IEnumerable count: {inputs?.Count()}");
foreach (var item in inputs)
{
_logger.LogInformation($"{item}");
}
}

[Function("MyEventHubTriggerList")]
public void Run2([EventHubTrigger("samples-workitems", Connection = "Con")] List inputs)
{
_logger.LogInformation($"List Length: {inputs.Count}");
foreach (var item in inputs)
{
_logger.LogInformation($"{item}");
}
}
```

Works fine for `IEnumerable`, `ICollection`, `IList` and `IReadOnlyList`. `List` is the one unhappy puppy.

When target type is `IEnumerable`, `ICollection`, `IList` or `IReadOnlyList`, The [TypeConverter ](https://github.com/Azure/azure-functions-dotnet-worker/blob/2b78e7b03503f499ae71507b2a842d1848b86fb2/src/DotNetWorker.Core/Converters/TypeConverter.cs#L9) does the conversion. But it does not work for array or List.

![image](https://user-images.githubusercontent.com/144469/221059319-e9d42bd1-c065-483c-b4bb-e3f540923fa9.png)

When target type is `string[`], the [TypeConverter ](https://github.com/Azure/azure-functions-dotnet-worker/blob/2b78e7b03503f499ae71507b2a842d1848b86fb2/src/DotNetWorker.Core/Converters/TypeConverter.cs#L9) still returns an unhandled response, but the [ArrayConverter ](https://github.com/Azure/azure-functions-dotnet-worker/blob/2b78e7b03503f499ae71507b2a842d1848b86fb2/src/DotNetWorker.Core/Converters/ArrayConverter.cs#L12)can successfully convert.

![image](https://user-images.githubusercontent.com/144469/221059769-bcbd02a8-30a9-497e-aec5-3e18bba6d7e2.png)

In short, we do not have a converter which is able to convert when target type is `List` in this example.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.