[KafkaTrigger] Errors while retrieving function metadata using BindingName in cardinality=Cardinality.MANY mode
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 48/100
Research direction
Start by tracing the conversion path in DataOperations.apply, DataSource.computeByType, and the RpcCollectionLongDataSource and RpcCollectionStringDataSource classes named in the traces. Reproduce the Kafka trigger with Cardinality.MANY and the OffsetArray and TopicArray bindings. Done means these metadata arrays no longer cause ClassCastException and the existing bindings still resolve correctly.
Written by the indexing model from the issue text.
Description
Kafka trigger function has these metadata: Offset (long), Topic (string), key, partition, timestamp and headers. I was able to retrieve all this data using a basic function:
public class KafkaTriggerJava {
@FunctionName("KafkaTriggerJava")
public void run(
@KafkaTrigger(
name = "kafkaTrigger",
topic = "test-topic",
brokerList = "localhost:9092",
authenticationMode = BrokerAuthenticationMode.PLAIN,
protocol = BrokerProtocol.PLAINTEXT,
consumerGroup = "test-group")
String kafkaEventData,
@BindingName("Key") String key,
@BindingName("Offset") int offset,
@BindingName("Partition") int partition,
final ExecutionContext context) {
context.getLogger().info("Payload: " + kafkaEventData);
}
}
Then I set cardinality=Cardinality.MANY and tried the following binding names:
@BindingName("KeyArray") Object[] key,
@BindingName("OffsetArray") Object[] offset,
@BindingName("TopicArray") Object[] topic,
@BindingName("PartitionArray") Object[] partition,
@BindingName("TimestampArray") Object[] timestamp,
@BindingName("HeadersArray") String[] headers
While I was able to get some of the data, "OffsetArray" and "TopicArray" ran into data conversion errors.
Trace for "OffsetArray":
Exception: ClassCastException: class com.microsoft.azure.functions.shaded.com.google.protobuf.LongArrayList cannot be cast to class java.lang.String (com.microsoft.azure.functions.shaded.com.google.protobuf.LongArrayList is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap')
Stack: java.lang.ClassCastException: class com.microsoft.azure.functions.shaded.com.google.protobuf.LongArrayList cannot be cast to class java.lang.String (com.microsoft.azure.functions.shaded.com.google.protobuf.LongArrayList is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap')
[2025-10-29T05:03:58.349Z] at com.microsoft.azure.functions.worker.binding.DataOperations.apply(DataOperations.java:99)
[2025-10-29T05:03:58.352Z] at com.microsoft.azure.functions.worker.binding.DataSource.computeByType(DataSource.java:56)
[2025-10-29T05:03:58.354Z] at com.microsoft.azure.functions.worker.binding.RpcCollectionLongDataSource.computeByType(RpcCollectionLongDataSource.java:10)
[2025-10-29T05:03:58.356Z] at com.microsoft.azure.functions.worker.binding.DataSource.computeByName(DataSource.java:42)
[2025-10-29T05:03:58.359Z] at com.microsoft.azure.functions.worker.binding.RpcCollectionLongDataSource.computeByName(RpcCollectionLongDataSource.java:10)
[2025-10-29T05:03:58.361Z] at com.microsoft.azure.functions.worker.binding.BindingDataStore.getTriggerMetatDataByName(BindingDataStore.java:72)
[2025-10-29T05:03:58.363Z] at com.microsoft.azure.functions.worker.broker.ParameterResolver.resolve(ParameterResolver.java:47)
[2025-10-29T05:03:58.365Z] at com.microsoft.azure.functions.worker.broker.ParameterResolver.resolveArguments(ParameterResolver.java:22)
[2025-10-29T05:03:58.367Z] at com.microsoft.azure.functions.worker.broker.EnhancedJavaMethodExecutorImpl.execute(EnhancedJavaMethodExecutorImpl.java:20)
[2025-10-29T05:03:58.370Z] at com.microsoft.azure.functions.worker.chain.FunctionExecutionMiddleware.invoke(FunctionExecutionMiddleware.java:19)
[2025-10-29T05:03:58.372Z] at com.microsoft.azure.functions.worker.chain.InvocationChain.doNext(InvocationChain.java:21)
[2025-10-29T05:03:58.374Z] at com.microsoft.azure.functions.worker.broker.JavaFunctionBroker.invokeMethod(JavaFunctionBroker.java:198)
[2025-10-29T05:03:58.376Z] at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:34)
[2025-10-29T05:03:58.378Z] at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:10)
[2025-10-29T05:03:58.380Z] at com.microsoft.azure.functions.worker.handler.MessageHandler.handle(MessageHandler.java:44)
[2025-10-29T05:03:58.383Z] at com.microsoft.azure.functions.worker.JavaWorkerClient$StreamingMessagePeer.lambda$onNext$0(JavaWorkerClient.java:94)
[2025-10-29T05:03:58.385Z] at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[2025-10-29T05:03:58.387Z] at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[2025-10-29T05:03:58.390Z] at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[2025-10-29T05:03:58.392Z] at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[2025-10-29T05:03:58.394Z] at java.base/java.lang.Thread.run(Thread.java:834)
Trace for "TopicArray":
Exception: ClassCastException: class com.microsoft.azure.functions.shaded.com.google.protobuf.LazyStringArrayList cannot be cast to class java.lang.String (com.microsoft.azure.functions.shaded.com.google.protobuf.LazyStringArrayList is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap')
Stack: java.lang.ClassCastException: class com.microsoft.azure.functions.shaded.com.google.protobuf.LazyStringArrayList cannot be cast to class java.lang.String (com.microsoft.azure.functions.shaded.com.google.protobuf.LazyStringArrayList is in unnamed module of loader 'app'; java.lang.String is in module java.base of loader 'bootstrap')
[2025-10-29T04:43:25.493Z] at com.microsoft.azure.functions.worker.binding.DataOperations.apply(DataOperations.java:99)
[2025-10-29T04:43:25.495Z] at com.microsoft.azure.functions.worker.binding.DataSource.computeByType(DataSource.java:56)
[2025-10-29T04:43:25.498Z] at com.microsoft.azure.functions.worker.binding.RpcCollectionStringDataSource.computeByType(RpcCollectionStringDataSource.java:10)
[2025-10-29T04:43:25.500Z] at com.microsoft.azure.functions.worker.binding.DataSource.computeByName(DataSource.java:42)
[2025-10-29T04:43:25.503Z] at com.microsoft.azure.functions.worker.binding.RpcCollectionStringDataSource.computeByName(RpcCollectionStringDataSource.java:10)
[2025-10-29T04:43:25.506Z] at com.microsoft.azure.functions.worker.binding.BindingDataStore.getTriggerMetatDataByName(BindingDataStore.java:72)
[2025-10-29T04:43:25.509Z] at com.microsoft.azure.functions.worker.broker.ParameterResolver.resolve(ParameterResolver.java:47)
[2025-10-29T04:43:25.512Z] at com.microsoft.azure.functions.worker.broker.ParameterResolver.resolveArguments(ParameterResolver.java:22)
[2025-10-29T04:43:25.515Z] at com.microsoft.azure.functions.worker.broker.EnhancedJavaMethodExecutorImpl.execute(EnhancedJavaMethodExecutorImpl.java:20)
[2025-10-29T04:43:25.518Z] at com.microsoft.azure.functions.worker.chain.FunctionExecutionMiddleware.invoke(FunctionExecutionMiddleware.java:19)
[2025-10-29T04:43:25.521Z] at com.microsoft.azure.functions.worker.chain.InvocationChain.doNext(InvocationChain.java:21)
[2025-10-29T04:43:25.525Z] at com.microsoft.azure.functions.worker.broker.JavaFunctionBroker.invokeMethod(JavaFunctionBroker.java:198)
[2025-10-29T04:43:25.528Z] at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:34)
[2025-10-29T04:43:25.532Z] at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:10)
[2025-10-29T04:43:25.536Z] at com.microsoft.azure.functions.worker.handler.MessageHandler.handle(MessageHandler.java:44)
[2025-10-29T04:43:25.539Z] at com.microsoft.azure.functions.worker.JavaWorkerClient$StreamingMessagePeer.lambda$onNext$0(JavaWorkerClient.java:94)
[2025-10-29T04:43:25.543Z] at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
[2025-10-29T04:43:25.547Z] at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[2025-10-29T04:43:25.550Z] at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
[2025-10-29T04:43:25.553Z] at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
[2025-10-29T04:43:25.556Z] at java.base/java.lang.Thread.run(Thread.java:834)
- Dominant language
- Java
- Stars
- 45
- Forks
- 49
- PR merge metrics
- No merged PRs in 30d
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Azure/azure-functions-java-library
-
area:java-functions
Difficulty 4/5 3-5 days Newbie friendliness 35/100
Azure/azure-functions-java-library#222 · 1 reaction ·
-
Difficulty 4/5 3-5 days Newbie friendliness 35/100
-
area:java-functions
Difficulty 2/5 1-3 hours Newbie friendliness 45/100
-
area:java-functions
Difficulty 5/5 Over a week Newbie friendliness 25/100
-
area:java-functions
Difficulty 3/5 1-2 days Newbie friendliness 35/100
All issues in Azure/azure-functions-java-library
Similar issues
-
area/plugin
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
kestra-io/plugin-kestra#190 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 70/100
google-ai-edge/LiteRT-LM#3739 ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
integra-team-red/meet-map#249 ·
-
[Studio][Bug] Cancelled create-user dialog keeps the password and admin switch for the next attempt Open
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
apache/rocketmq-dashboard#5064 ·