Azure / Azure/azure-functions-java-worker

[BUG] Duplicated field "client" in BlockBlobClient, raises gson IllegalArgumentException

Abierto
#827 1 comentario 0 reacciones 1 asignado Reclamado por @ahmedmuhsin Ver en GitHub
area:java-functions
Lenguaje dominante
Java
Estrellas
103
Forks
74
Merge medio
4 d 8 h
PR fusionados (30 d)
2

Descripción

**Describe the bug**
- I created a simple function app to learn about blob triggers, following this reference [Azure Blob storage trigger for Azure Functions](https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-blob-trigger?tabs=python-v2%2Cisolated-process%2Cnodejs-v4%2Cextensionv5&pivots=programming-language-java#example)
- I'm trying to create a Function App to be triggered by blob storage events, and would like to retrieve the file metadata fields to use as parameters to file processing logic.
- But when I declare @BlobTrigger in a BlobClient blobClient, raises the exception below. If I change to String content (or byte[]) the trigger works as expected.
- I tried to remove gson as a indirect dependency in pom.xml, also tried to declare jackson to be the default serialized, but no success.
- I managed to create by hand the blobClient and reach the file metadata, but I think that's not the right approach.

***Exception or Stack Trace***
```
Executing 'Functions.processBlob' (Reason='New blob detected(LogsAndContainerScan): my_blob_storage/my_folder/my_file.csv', Id=bb2845c7-9d8c-4ecd-b6e0-21b42b73a345)
[2025-07-09T20:58:04.183Z] Trigger Details: MessageId: 28459ab1-e4de-4c2d-9bfb-901df92c32de, DequeueCount: 1, InsertedOn: 2025-07-09T20:58:03.000+00:00, BlobCreated: 2025-07-09T17:55:50.000+00:00, BlobLastModified: 2025-07-09T20:58:02.000+00:00
[2025-07-09T20:58:04.209Z] Executed 'Functions.processBlob' (Failed, Id=bb2845c7-9d8c-4ecd-b6e0-21b42b73a345, Duration=30ms)
[2025-07-09T20:58:04.209Z] System.Private.CoreLib: Exception while executing function: Functions.processBlob. System.Private.CoreLib: Result: Failure
[2025-07-09T20:58:04.209Z] Exception: IllegalArgumentException: Class com.azure.storage.blob.specialized.BlockBlobClient declares multiple JSON fields named 'client'; conflict is caused by fields com.azure.storage.blob.specialized.BlockBlobClient#client and com.azure.storage.blob.specialized.BlobClientBase#client
[2025-07-09T20:58:04.209Z] See https://github.com/google/gson/blob/main/Troubleshooting.md#duplicate-fields
[2025-07-09T20:58:04.210Z] Stack: java.lang.IllegalArgumentException: Class com.azure.storage.blob.specialized.BlockBlobClient declares multiple JSON fields named 'client'; conflict is caused by fields com.azure.storage.blob.specialized.BlockBlobClient#client and com.azure.storage.blob.specialized.BlobClientBase#client
[2025-07-09T20:58:04.210Z] See https://github.com/google/gson/blob/main/Troubleshooting.md#duplicate-fields
[2025-07-09T20:58:04.210Z] at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createDuplicateFieldException(ReflectiveTypeAdapterFactory.java:313)
[2025-07-09T20:58:04.210Z] at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:409)
[2025-07-09T20:58:04.210Z] at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:161)
[2025-07-09T20:58:04.210Z] at com.google.gson.Gson.getAdapter(Gson.java:628)
[2025-07-09T20:58:04.210Z] at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.createBoundField(ReflectiveTypeAdapterFactory.java:201)
[2025-07-09T20:58:04.210Z] at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.getBoundFields(ReflectiveTypeAdapterFactory.java:395)
[2025-07-09T20:58:04.210Z] at com.google.gson.internal.bind.ReflectiveTypeAdapterFactory.create(ReflectiveTypeAdapterFactory.java:161)
[2025-07-09T20:58:04.210Z] at com.google.gson.Gson.getAdapter(Gson.java:628)
[2025-07-09T20:58:04.211Z] at com.google.gson.Gson.fromJson(Gson.java:1360)
[2025-07-09T20:58:04.211Z] at com.google.gson.Gson.fromJson(Gson.java:1262)
[2025-07-09T20:58:04.211Z] at com.google.gson.Gson.fromJson(Gson.java:1171)
[2025-07-09T20:58:04.211Z] at com.google.gson.Gson.fromJson(Gson.java:1137)
[2025-07-09T20:58:04.211Z] at com.microsoft.azure.functions.worker.binding.DataOperations.convertFromJson(DataOperations.java:158)
[2025-07-09T20:58:04.211Z] at com.microsoft.azure.functions.worker.binding.DataOperations.apply(DataOperations.java:114)
[2025-07-09T20:58:04.211Z] at com.microsoft.azure.functions.worker.binding.DataSource.computeByType(DataSource.java:56)
[2025-07-09T20:58:04.211Z] at com.microsoft.azure.functions.worker.binding.RpcStringDataSource.computeByType(RpcStringDataSource.java:5)
[2025-07-09T20:58:04.211Z] at com.microsoft.azure.functions.worker.binding.DataSource.computeByName(DataSource.java:42)
[2025-07-09T20:58:04.211Z] at com.microsoft.azure.functions.worker.binding.RpcStringDataSource.computeByName(RpcStringDataSource.java:5)
[2025-07-09T20:58:04.211Z] at com.microsoft.azure.functions.worker.binding.BindingDataStore.getDataByName(BindingDataStore.java:66)
[2025-07-09T20:58:04.212Z] at com.microsoft.azure.functions.worker.binding.ExecutionContextDataSource.getBindingData(ExecutionContextDataSource.java:181)
[2025-07-09T20:58:04.212Z] at com.microsoft.azure.functions.worker.broker.ParameterResolver.resolve(ParameterResolver.java:44)
[2025-07-09T20:58:04.212Z] at com.microsoft.azure.functions.worker.broker.ParameterResolver.resolveArguments(ParameterResolver.java:22)
[2025-07-09T20:58:04.212Z] at com.microsoft.azure.functions.worker.broker.EnhancedJavaMethodExecutorImpl.execute(EnhancedJavaMethodExecutorImpl.java:20)
[2025-07-09T20:58:04.212Z] at com.microsoft.azure.functions.worker.chain.FunctionExecutionMiddleware.invoke(FunctionExecutionMiddleware.java:19)
[2025-07-09T20:58:04.212Z] at com.microsoft.azure.functions.worker.chain.InvocationChain.doNext(InvocationChain.java:21)
[2025-07-09T20:58:04.212Z] at com.microsoft.azure.functions.worker.broker.JavaFunctionBroker.invokeMethod(JavaFunctionBroker.java:195)
[2025-07-09T20:58:04.212Z] at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:34)
[2025-07-09T20:58:04.212Z] at com.microsoft.azure.functions.worker.handler.InvocationRequestHandler.execute(InvocationRequestHandler.java:10)
[2025-07-09T20:58:04.212Z] at com.microsoft.azure.functions.worker.handler.MessageHandler.handle(MessageHandler.java:44)
[2025-07-09T20:58:04.213Z] at com.microsoft.azure.functions.worker.JavaWorkerClient$StreamingMessagePeer.lambda$onNext$0(JavaWorkerClient.java:94)
[2025-07-09T20:58:04.213Z] at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
[2025-07-09T20:58:04.213Z] at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
[2025-07-09T20:58:04.213Z] at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
[2025-07-09T20:58:04.213Z] at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
[2025-07-09T20:58:04.213Z] at java.base/java.lang.Thread.run(Thread.java:840)
```
**To Reproduce**
- Create a simple function app in java, with blob trigger
- Declare a method with @BlobTrigger annotation to BlobClient variable
- Start the function app and upload a file to the monitoring folder

***Code Snippet***
```
public class FunctionTriggers {

@FunctionName("processBlob")
public void run(
@BlobTrigger(name = "content", path = "my_blob_storage/my_folder/{fileName}", connection = "SourceBlogStorageConnStr") BlobClient blobClient,
@BindingName("fileName") String fileName,
ExecutionContext ctx) {

ctx.getLogger().info("Size = " + blobClient.getProperties().getBlobSize());
ctx.getLogger().info("Filename = " + fileName);
ctx.getLogger().info("Metadata = " + blobClient.getProperties().getMetadata().entrySet());
}
}
```

**Expected behavior**
- Code runs sucessfully, just like it expected.

**Setup (please complete the following information):**
- OS: Darwin arm64 24.5.0
- IDE: VS Code 1.101.0
Commit: dfaf44141ea9deb3b4096f7cd6d24e00c147a4b1
Date: 2025-06-11T15:00:50.123Z
Electron: 35.5.1
ElectronBuildId: 11727614
Chromium: 134.0.6998.205
Node.js: 22.15.1
V8: 13.4.114.21-electron.0
- Library/Libraries: azure-storage-blob : 12.28.0
- Library/Libraries: azure-functions-java-library : 3.1.0
- Java version: 17
- App Server/Environment: Azure Function
- Frameworks: Guice 5.1.0

Guía de contribución

Abrir la guía de contribución

Evaluación

Este issue todavía no se ha evaluado.

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.