Skip to content

receiver.peek_messages() fails for some queues and works for others #38717

@amiket-srivastava

Description

@amiket-srivastava
  • Package Name: azure-servicebus
  • Package Version: 7.13.0
  • Operating System: Windows 11 Pro and Linux as well (tested on both OS)
  • Python Version: 3.12.7

Describe the bug
I get an error when I try to peek messages on some of my Azure service bus queues. It works well with other queues but fails with some (I have same permissions to both). The only difference between the queues is that the one which fails has two additional custom properties and a bigger body (131B vs 921 B). I tried using with both uamqp_transport=True and False but got different errors both times for the failing queues:

################ This is for uamqp_transport=False ####################

Unexpected error occurred (TypeError("'NoneType' object is not callable")). Handler shutting down.
Traceback (most recent call last):
File "C:\Users\amiket.srivastava\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\azure\servicebus_base_handler.py", line 378, in _do_retryable_operation
return operation(**kwargs)
^^^^^^^^^^^^^^^^^^^
File "C:\Users\amiket.srivastava\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\azure\servicebus_base_handler.py", line 501, in _mgmt_request_response
return self._amqp_transport.mgmt_client_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\amiket.srivastava\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\azure\servicebus_transport_pyamqp_transport.py", line 923, in mgmt_client_request
return callback(status, response, description, amqp_transport=PyamqpTransport)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\amiket.srivastava\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\azure\servicebus_common\mgmt_handlers.py", line 55, in peek_op
return amqp_transport.parse_received_message(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\amiket.srivastava\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\azure\servicebus_transport_pyamqp_transport.py", line 824, in parse_received_message
wrapped = decode_payload(memoryview(m[b"message"]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\amiket.srivastava\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\azure\servicebus_pyamqp_decode.py", line 235, in decode_payload
buffer, value = _DECODE_BY_CONSTRUCTORbuffer[3]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\amiket.srivastava\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.12_qbz5n2kfra8p0\LocalCache\local-packages\Python312\site-packages\azure\servicebus_pyamqp_decode.py", line 176, in _decode_map_small
buffer, value = _DECODE_BY_CONSTRUCTORbuffer[0]
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
TypeError: 'NoneType' object is not callable

##############################################################

################ This is for uamqp_transport=True and also run on Linux machine ####################

Traceback (most recent call last):
File "/tmp/8dd0e2cfbcafaa2/antenv/lib/python3.12/site-packages/azure/servicebus/_base_handler.py", line 411, in _do_retryable_operation
return operation(**kwargs)
^^^^^^^^^^^^^^^^^^^
File "/tmp/8dd0e2cfbcafaa2/antenv/lib/python3.12/site-packages/azure/servicebus/_base_handler.py", line 530, in _mgmt_request_response
return self._amqp_transport.mgmt_client_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/8dd0e2cfbcafaa2/antenv/lib/python3.12/site-packages/azure/servicebus/_transport/_uamqp_transport.py", line 1014, in mgmt_client_request
return mgmt_client.mgmt_request(
^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/8dd0e2cfbcafaa2/antenv/lib/python3.12/site-packages/uamqp/client.py", line 343, in mgmt_request
response = self._session.mgmt_request(
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/8dd0e2cfbcafaa2/antenv/lib/python3.12/site-packages/uamqp/session.py", line 126, in mgmt_request
return parse_response(status, response, description)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/8dd0e2cfbcafaa2/antenv/lib/python3.12/site-packages/azure/servicebus/_common/mgmt_handlers.py", line 65, in peek_op
return amqp_transport.parse_received_message(
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/8dd0e2cfbcafaa2/antenv/lib/python3.12/site-packages/azure/servicebus/_transport/_uamqp_transport.py", line 917, in parse_received_message
wrapped = Message.decode_from_bytes(bytearray(m[b"message"]))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/tmp/8dd0e2cfbcafaa2/antenv/lib/python3.12/site-packages/uamqp/message.py", line 283, in decode_from_bytes
decoded_message = c_uamqp.decode_message(len(data), data)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "./src/message.pyx", line 769, in uamqp.c_uamqp.decode_message
File "./src/message.pyx", line 779, in uamqp.c_uamqp.decode_message
ValueError: Cannot decode bytes

###############################################################

To Reproduce
Steps to reproduce the behavior:

  1. Create an Azure Service Bus Queue and provide permissions
  2. Send the message I have attached to it.
  3. Try to peek it using the following code:

##############
import os
from azure.servicebus import ServiceBusClient
from azure.identity import DefaultAzureCredential

FULLY_QUALIFIED_NAMESPACE = os.environ["SERVICEBUS_FULLY_QUALIFIED_NAMESPACE"]
QUEUE_NAME = os.environ["SERVICEBUS_QUEUE_NAME"]

credential = DefaultAzureCredential()
servicebus_client = ServiceBusClient(FULLY_QUALIFIED_NAMESPACE, credential)

with servicebus_client:
receiver = servicebus_client.get_queue_receiver(queue_name=QUEUE_NAME)
with receiver:
received_msgs = receiver.peek_messages(max_message_count=2)
for msg in received_msgs:
print(str(msg))
#######################

Expected behavior
I expected to get the peeked the messaged in response instead of the error.

Screenshots

N/A as Already shared the errors encountered in text format.

Additional context
Add any other context about the problem here.

Metadata

Metadata

Labels

ClientThis issue points to a problem in the data-plane of the library.MessagingMessaging crewService BusbugThis issue requires a change to an existing behavior in the product in order to be resolved.customer-reportedIssues that are reported by GitHub users external to the Azure organization.issue-addressedWorkflow: The Azure SDK team believes it to be addressed and ready to close.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions