Encode AMQP 1.0 arrays of zero-octet elements as opaque values#16994
Merged
Conversation
## What?
The AMQP 1.0 binary parser (amqp10_binary_parser) decoded an array
whose element constructor has a zero-octet wire encoding (null, true,
false, uint0, ulong0, list0 - wire codes 0x40-0x45) by expanding it
into a full Erlang list, one term per element, via lists:duplicate/2.
It now instead represents such an array as an opaque value ({as_is,
TypeCode, Bin}), the same representation already used for decimal and
NaN/Infinity values that RabbitMQ has no need to interpret further.
## Why
For this class of array, the element count is carried in a small,
fixed-size wire encoding, while the previous implementation allocated
one term per element when decoding it. This meant the memory needed to
hold the decoded value had no relationship to the size of the input
that produced it. Representing the value opaquely removes that
mismatch entirely, rather than merely capping it, and keeps the parser
consistent with how it already treats other value kinds it does not
need to interpret.
|
Tick the box to add this pull request to the merge queue (same as
|
lhoguin
approved these changes
Jul 21, 2026
lhoguin
left a comment
Contributor
There was a problem hiding this comment.
If you don't need them then yes not decoding them is the way to go.
michaelklishin
approved these changes
Jul 21, 2026
michaelklishin
left a comment
Collaborator
There was a problem hiding this comment.
This is an elegant solution that still addresses the issue at hand. I have tried with a 130M element modification across thousands of collections and it does work as expected.
michaelklishin
added a commit
that referenced
this pull request
Jul 22, 2026
Encode AMQP 1.0 arrays of zero-octet elements as opaque values (backport #16994)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What?
The AMQP 1.0 binary parser (amqp10_binary_parser) decoded an array whose element constructor has a zero-octet wire encoding (null, true, false, uint0, ulong0, list0 - wire codes 0x40-0x45) by expanding it into a full Erlang list, one term per element, via lists:duplicate/2. It now instead represents such an array as an opaque value ({as_is, TypeCode, Bin}), the same representation already used for decimal and NaN/Infinity values that RabbitMQ has no need to interpret further.
Why
For this class of array, the element count is carried in a small, fixed-size wire encoding, while the previous implementation allocated one term per element when decoding it. This meant the memory needed to hold the decoded value had no relationship to the size of the input that produced it. Representing the value opaquely removes that mismatch entirely, rather than merely capping it, and keeps the parser consistent with how it already treats other value kinds it does not need to interpret.
Supersedes #16986