Fix OptionalNbt framing: VarInt byte length, not bool presence - #335
Open
etz wants to merge 2 commits into
Open
Conversation
etz
force-pushed
the
fix/optional-nbt-varint-length-clean
branch
from
June 4, 2026 22:08
a1858f3 to
4e972d9
Compare
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.
The serverbound
custom_click_actionpayload is currently encoded as bare unnamed NBT, but vanilla expects a VarInt byte length followed by unnamed NBT (with0meaning absent). Empty payloads happen to round-trip becauseNbt::Nonewrites0x00and that's also the VarInt zero-length sentinel, which is probably why this hasn't surfaced before — any non-empty submission disconnects.Repro on a vanilla 26.1.2 server with an OP'd offline user and a tiny
minecraft:noticedialog datapack with a text input. Submitting the dialog from unpatched azalea:Outgoing payload after the action id, unpatched vs. patched:
9c 01is the VarInt for the 156-byte NBT payload that follows.The fix adds an
OptionalNbtnewtype whoseAzBufimpl reads/writes the VarInt-length framing, and switches boths_custom_click_action.rs(config + game) to use it.Regression tests live in
azalea-protocol/tests/optional_nbt.rs(minimal present payload, absent payload, vanilla-shaped dialog payload withargs/cmd/fieldkeys).The first commit also contains a few mechanical clippy fixes in unrelated existing code — without them
cargo clippy -p azalea-protocol --all-targets -- -D warningsdoesn't pass on the base, so the new tests can't be gated on it cleanly. Happy to drop that commit if you'd rather it land separately.One thing worth a second pair of eyes: I only found two packets that use this framing today. If you know of others that should switch to
OptionalNbt, point me at them.