azure-sdk-for-python
azure-sdk-for-python copied to clipboard
azure-servicebus raise ValueError. ERROR:azure.servicebus.aio._base_handler_async:Unexpected error occurred (ValueError('Value supplied for int invalid: 1709502629433')). Handler shutting down.
- Package Name: azure-servicebus
- Package Version: 7.11.4
- Operating System: Ubuntu
- Python Version: python:3.9.10-slim
Describe the bug When I send a message from the dead letter queue to the normal queue, an exception is thrown at this time. For example:
ERROR:azure.servicebus.aio._base_handler_async:Unexpected error occurred (ValueError('Value supplied for int invalid: 1709502629433')). Handler shutting down.
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/azure/servicebus/_pyamqp/_encode.py", line 265, in encode_int
output.extend(struct.pack(">i", value))
struct.error: 'i' format requires -2147483648 <= number <= 2147483647
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "/usr/local/lib/python3.9/site-packages/azure/servicebus/aio/_base_handler_async.py", line 269, in _do_retryable_operation
return await operation(**kwargs)
File "/usr/local/lib/python3.9/site-packages/azure/servicebus/aio/_servicebus_sender_async.py", line 229, in _send
await self._amqp_transport.send_messages_async(
File "/usr/local/lib/python3.9/site-packages/azure/servicebus/aio/_transport/_pyamqp_transport_async.py", line 142, in send_messages_async
await sender._handler.send_message_async(
File "/usr/local/lib/python3.9/site-packages/azure/servicebus/_pyamqp/aio/_client_async.py", line 616, in send_message_async
await self._do_retryable_operation_async(self._send_message_impl_async, message=message, **kwargs)
File "/usr/local/lib/python3.9/site-packages/azure/servicebus/_pyamqp/aio/_client_async.py", line 212, in _do_retryable_operation_async
return await operation(*args, timeout=absolute_timeout, **kwargs)
File "/usr/local/lib/python3.9/site-packages/azure/servicebus/_pyamqp/aio/_client_async.py", line 594, in _send_message_impl_async
running = await self.do_work_async()
File "/usr/local/lib/python3.9/site-packages/azure/servicebus/_pyamqp/aio/_client_async.py", line 356, in do_work_async
return await self._client_run_async(**kwargs)
File "/usr/local/lib/python3.9/site-packages/azure/servicebus/_pyamqp/aio/_client_async.py", line 531, in _client_run_async
await self._link.update_pending_deliveries()
File "/usr/local/lib/python3.9/site-packages/azure/servicebus/_pyamqp/aio/_sender_async.py", line 161, in update_pending_deliveries
sent_and_settled = await self._outgoing_transfer(delivery)
File "/usr/local/lib/python3.9/site-packages/azure/servicebus/_pyamqp/aio/_sender_async.py", line 94, in _outgoing_transfer
encode_payload(output, delivery.message)
File "/usr/local/lib/python3.9/site-packages/azure/servicebus/_pyamqp/_encode.py", line 925, in encode_payload
encode_value(
File "/usr/local/lib/python3.9/site-packages/azure/servicebus/_pyamqp/_encode.py", line 859, in encode_value
cast(Callable, _ENCODE_MAP[value[TYPE]])(output, value[VALUE], **kwargs)
File "/usr/local/lib/python3.9/site-packages/azure/servicebus/_pyamqp/_encode.py", line 594, in encode_described
encode_value(output, value[1], **kwargs)
File "/usr/local/lib/python3.9/site-packages/azure/servicebus/_pyamqp/_encode.py", line 859, in encode_value
cast(Callable, _ENCODE_MAP[value[TYPE]])(output, value[VALUE], **kwargs)
File "/usr/local/lib/python3.9/site-packages/azure/servicebus/_pyamqp/_encode.py", line 518, in encode_map
encode_value(encoded_values, data, with_constructor=True)
File "/usr/local/lib/python3.9/site-packages/azure/servicebus/_pyamqp/_encode.py", line 859, in encode_value
cast(Callable, _ENCODE_MAP[value[TYPE]])(output, value[VALUE], **kwargs)
File "/usr/local/lib/python3.9/site-packages/azure/servicebus/_pyamqp/_encode.py", line 808, in encode_unknown
encode_int(output, value, **kwargs)
File "/usr/local/lib/python3.9/site-packages/azure/servicebus/_pyamqp/_encode.py", line 267, in encode_int
raise ValueError("Value supplied for int invalid: {}".format(value)) from exc
ValueError: Value supplied for int invalid: 1709502629433
While I add log print at azure/servicebus/_pyamqp/aio/_sender_async.py:L93
, the output is as follows:
Message(header=Header(durable=None, priority=None, ttl=1209600000, first_acquirer=None, delivery_count=0),
delivery_annotations={b'x-opt-lock-token': UUID('411b88b5-721f-4a20-934e-9d94324b0007')},
message_annotations={b'x-opt-scheduled-enqueue-time': 1709502629433,
b'x-opt-enqueued-time': {'TYPE': 'LONG', 'VALUE': 1709502629434}, b'x-opt-sequence-number': 1970324839875774, b'x-opt-partition-key': b'348', b'x-opt-partition-id': 7, b'x-opt-locked-until': {'TYPE': 'LONG', 'VALUE': 1710144727007}, b'x-opt-message-state': 0}, properties=Properties(message_id=b'1cae6f3d-48a3-403e-a700-bd60f45a78a4_2d52a0bc-a37f-4539-b39c-8fd0bed398eb', user_id=None, to=None, subject=None, reply_to=None, correlation_id=None, content_type=None, content_encoding=None, absolute_expiry_time=1711354297000, creation_time=1710144697000, group_id=None, group_sequence=None, reply_to_group_id=None), application_properties={...}'], sequence=None, value=None, footer=None)
I found the library think x-opt-scheduled-enqueue-time is int, and make sure the value in [-2147483648,2147483647], but it is millcseconds, beyond max integer value.
To Reproduce Steps to reproduce the behavior:
- Send an message to Servicebus;
- Put the message to dead-letter queue;
- get and complete message from dead-letter queue, resend the same message to normal queue and raise error.
Expected behavior The message can send to normal message normally.
Screenshots If applicable, add screenshots to help explain your problem.
Additional context Add any other context about the problem here.
Thank you for the feedback @sky94520. Are there any other details about your servicebus set up that would be needed to reproduce the issue ?
Ill update this issue once I can reproduce it.
Hi @sky94520, I was not able to reproduce the issue on my end using the following code snippet. Would you be able to provide an example that can show the error please ?
import os
from azure.servicebus import ServiceBusClient, ServiceBusMessage, ServiceBusSubQueue
import logging
import sys
from dotenv import find_dotenv, load_dotenv
load_dotenv(find_dotenv())
logger = logging.getLogger("azure")
logger.setLevel(logging.DEBUG)
handler = logging.StreamHandler(stream=sys.stdout)
logger.addHandler(handler)
CONNECTION_STR = os.environ['SERVICEBUS_CONNECTION_STR']
QUEUE_NAME = os.environ["SERVICEBUS_QUEUE_NAME"]
servicebus_client = ServiceBusClient.from_connection_string(conn_str=CONNECTION_STR)
with servicebus_client:
sender = servicebus_client.get_queue_sender(queue_name=QUEUE_NAME)
messages = [ServiceBusMessage("Message to be deadlettered") for _ in range(1)]
with sender:
sender.send_messages(messages)
print('dead lettering messages')
receiver = servicebus_client.get_queue_receiver(queue_name=QUEUE_NAME)
with receiver:
received_msgs = receiver.receive_messages(max_message_count=10, max_wait_time=5)
for msg in received_msgs:
print(str(msg))
receiver.dead_letter_message(msg)
print('receiving deadlettered messages')
dlq_receiver = servicebus_client.get_queue_receiver(queue_name=QUEUE_NAME, sub_queue=ServiceBusSubQueue.DEAD_LETTER)
with dlq_receiver:
received_msgs = dlq_receiver.receive_messages(max_message_count=10, max_wait_time=5)
for msg in received_msgs:
print(str(msg))
dlq_receiver.complete_message(msg)
sender = servicebus_client.get_queue_sender(queue_name=QUEUE_NAME)
with sender:
sender.send_messages(msg)
print("Receive is done.")
Hi @sky94520. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.
Hi @kashifkhan, thank your attention, I will upload my minial project soon.
Hi @sky94520. Thank you for opening this issue and giving us the opportunity to assist. To help our team better understand your issue and the details of your scenario please provide a response to the question asked above or the information requested above. This will help us more accurately address your issue.
Hi @sky94520, we're sending this friendly reminder because we haven't heard back from you in 7 days. We need more information about this issue to help address it. Please be sure to give us your input. If we don't hear back from you within 14 days of this comment the issue will be automatically closed. Thank you!