Skip to content

[EventHub][ServiceBus] Fix pyAMQP decode of performatives with omitted trailing null fields#47660

Draft
j7nw4r wants to merge 1 commit into
Azure:mainfrom
j7nw4r:fix/pyamqp-decode-short-list
Draft

[EventHub][ServiceBus] Fix pyAMQP decode of performatives with omitted trailing null fields#47660
j7nw4r wants to merge 1 commit into
Azure:mainfrom
j7nw4r:fix/pyamqp-decode-short-list

Conversation

@j7nw4r

@j7nw4r j7nw4r commented Jun 25, 2026

Copy link
Copy Markdown
Member

Summary

The pyAMQP transport crashes when decoding an AMQP performative whose trailing null fields were omitted by the sender. The decoded performative list is now padded to its full field count so positional field access and namedtuple unpacking remain safe, with omitted trailing fields reading back as null.

Motivation

AMQP 1.0 section 1.4 permits a sender to omit the trailing null fields of a described list, so an incoming performative can arrive shorter than its full field count. The decoder in _decode.py built the field list from the element count on the wire, and downstream consumers then read fixed positions (for example frame[9] for Open properties, and OpenFrame(*frame) namedtuple unpacking). On a short list this raised IndexError or TypeError. This is the receiver side of Azure/amqpnetlite#645: a spec-compliant sender that omits trailing nulls triggers the crash, while brokers and other AMQP stacks that bound decoding by the wire count are unaffected.

Changes

  • Pad the decoded performative field list in decode_frame up to the performative's full field count, derived from each performative's _definition and excluding the transfer payload slot, before any positional access or namedtuple unpacking, so omitted trailing fields read back as None.
  • Apply the same fix to both the Event Hubs and Service Bus vendored _pyamqp copies.
  • Add regression tests covering a short Open, a short Transfer with a trailing payload, and the per-performative field counts.
  • Add changelog entries and bump the azure-eventhub version to 5.15.2.

Test plan

  • azure-eventhub: pytest tests/pyamqp_tests/unittest/test_decode.py, 15 passed.
  • azure-servicebus: pytest tests/unittests/test_pyamqp_decode.py, 11 passed.

AMQP 1.0 section 1.4 lets a sender omit trailing null fields, so an
incoming performative described-list can be shorter than the full
field count. The pyAMQP decoder built the field list from the wire
count, and consumers then accessed fixed indices (frame[9],
OpenFrame(*frame)), raising IndexError/TypeError on a short list.

decode_frame now pads the decoded list up to the performative's full
field count, so omitted trailing fields read back as None. Applied to
both the Event Hubs and Service Bus vendored copies, with regression
tests and changelog entries.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant