Skip to content

Conversation

@zeroshade
Copy link
Member

Rationale for this change

Fixes #625

What changes are included in this PR?

When all values appended to a BinaryBuilder are empty (zero-length byte slices), they were incorrectly being treated as NULL values instead of valid empty slices. This occurred because the underlying buffer builder returned a buffer created from nil bytes, which caused slicing operations to return nil.

The fix ensures that when no data buffer is allocated (length = 0), we create a buffer with an empty slice []byte{} instead of nil, allowing proper distinction between NULL and empty values.

Are these changes tested?

Yes a test is added.

Are there any user-facing changes?

Just fixing the behavior.

When all values appended to a BinaryBuilder are empty (zero-length
byte slices), they were incorrectly being treated as NULL values
instead of valid empty slices. This occurred because the underlying
buffer builder returned a buffer created from nil bytes, which caused
slicing operations to return nil.

The fix ensures that when no data buffer is allocated (length = 0),
we create a buffer with an empty slice []byte{} instead of nil,
allowing proper distinction between NULL and empty values.

Fixes apache#625
@zeroshade zeroshade requested review from amoeba, kou and lidavidm January 14, 2026 20:45
…s behavior

After fixing BinaryBuilder to properly distinguish between empty byte
slices and NULL values, the test expectation needed to be updated.

Empty byte slices ([]byte{}) now correctly serialize as empty strings ""
rather than null in JSON, which is the correct and expected behavior.

Related to apache#625
@zeroshade zeroshade merged commit 80700fd into apache:main Jan 15, 2026
42 of 45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Go] BinaryBuilder Append() doesn't append the empty values correctly

2 participants