Azure / azure-functions-servicebus-extension

Service Bus extension for Azure Functions
MIT License
65 stars 35 forks source link

[BUG] ServiceBus Trigger Cardinality: Many loses data of timestamps inside body. #232

Open ks-vdk opened 5 months ago

ks-vdk commented 5 months ago

Hello,

It seems that the input binding for the service-bus queue trigger loses data when cardinality is set to many. When I provide the following JSON:

{"value": "2024-01-19T12:50:41.250940Z"}

The function app reports the following log: image

When I run the same message, but not many cardinality, the correct response is produced.

image

This only seems to be an issue when the last value of the timestamp is 0.

Investigative information

Please provide the following:

Repro steps

Provide the steps required to reproduce the problem:

Send message on service bus with a timestamp in a json. Have a function-trigger read the message and log the result of get_body()

(Check source code for reproduction).

Notice the different results for cardinality.many and for not.

Expected behavior

Provide a description of the expected behavior.

Expected behavior is to return the correct data in bytes. {"value": "2024-01-19T12:50:41.250940Z"}

I raised an error on purpose so the message ends up in the dead letter queue instead of completed. This is the screenshot of the message in the dead-letter queue with the 0:

image

Actual behavior

Provide a description of the actual behavior observed.

Returns : {"value": "2024-01-19T12:50:41.25094Z"}

Notice the 0 missing before the Z

Known workarounds

Provide a description of any known workarounds.

Contents of the requirements.txt file:

Provide the requirements.txt file to help us find out module related issues.
aiohttp==3.8.6
azure-functions==1.18.0
azure-functions-durable==1.2.8
azure-identity==1.15.0
azure-mgmt-servicebus==8.2.0
azure-mgmt-authorization==4.0.0
azure-mgmt-apimanagement==4.0.0
azure-servicebus==7.11.4
azure-storage-blob==12.19.0
cryptography==41.0.7
pandas==2.1.3
pydantic==2.5.1
pydantic[email]==2.5.1
pyodbc==5.0.1
pyproj==3.6.1
reportlab==4.0.8
shapely==2.0.2
sqlalchemy==2.0.23
azure-keyvault-certificates==4.7.0

Related information

Provide any related information

Source code to reproduce.

Source ```python bp = func.Blueprint() @bp.function_name( f"Test-Trigger-Please-Delete", ) @bp.service_bus_queue_trigger( arg_name="inmsglist", queue_name="system-mgmt-test-queue", connection=CS_SERVICE_BUS.setting_name, cardinality=func.Cardinality.MANY, ) async def in_msg_trigger(inmsglist, context: func.Context) -> None: # noqa: ANN001 """Input trigger for messages arriving in the netid input queue. Args: inmsglist (list[func.ServiceBusMessage]): Incoming messages. context (func.Context): context of the invocation """ message: func.ServiceBusMessage for message in inmsglist: logging.info(message.get_body()) @bp.function_name( f"Test-Trigger-Please-Delete2", ) @bp.service_bus_queue_trigger( arg_name="message", queue_name="system-mgmt-test-queue2", connection=CS_SERVICE_BUS.setting_name, ) async def in_msg_trigger2( message: func.ServiceBusMessage, context: func.Context ) -> None: # noqa: ANN001 """Input trigger for messages arriving in the netid input queue. Args: inmsglist (list[func.ServiceBusMessage]): Incoming message. context (func.Context): context of the invocation """ logging.info(message.get_body()) ``` ```txt aiohttp==3.8.6 azure-functions==1.18.0 azure-functions-durable==1.2.8 azure-identity==1.15.0 azure-mgmt-servicebus==8.2.0 azure-mgmt-authorization==4.0.0 azure-mgmt-apimanagement==4.0.0 azure-servicebus==7.11.4 azure-storage-blob==12.19.0 cryptography==41.0.7 pandas==2.1.3 pydantic==2.5.1 pydantic[email]==2.5.1 pyodbc==5.0.1 pyproj==3.6.1 reportlab==4.0.8 shapely==2.0.2 sqlalchemy==2.0.23 azure-keyvault-certificates==4.7.0 ```
bhagyshricompany commented 5 months ago

Thanks for reporting will check and update.Thanks

ks-vdk commented 5 months ago

I'd like to add a few additional comments:

It doesn't matter if the timezone is Z or +00:00, the behavior is observed in both cases.

When using the azure.servicebus sdk, I do not have this problem. It seems to exist only in the azure function binding.

bhagyshricompany commented 4 months ago

@gavin-aguiar pls comment.