Repository navigation
fix(parquet/variant): return "" for an empty long-form string - #1353
Merged
zeroshade merged 1 commit intoOct 6, 2026
Merged
Conversation
Value() built a long-form string with unsafe.String(&v.value[5], sz). For an empty string the encoded value is only the 5-byte header and length, so &v.value[5] was out of range and Value() panicked, and String() and MarshalJSON() with it. validatePrimitiveValue accepts the encoding, so the value comes back from variant.New without an error. Guard it the way the short-string branch already does, and add a test for the empty and non-empty long forms. Fixes #1344
zeroshade
approved these changes
Oct 5, 2026
zeroshade
left a comment
Member
There was a problem hiding this comment.
Thanks for the fix. The guard mirrors the short-string branch, and I confirmed the new test panics on main (index out of range [5] with length 5) and passes here; the full parquet/variant suite is green. The sibling PrimitiveBinary branch is already safe for a zero length (v.value[5:5]), so nothing else needs the same treatment. LGTM.
This review was drafted by an AI-assisted tool and
confirmed by an Apache Arrow maintainer. The maintainer
approving this PR has read the findings and signed off. If
something feels off, please reply on the PR and a maintainer
will follow up.More on how Apache Arrow handles maintainer review:
CONTRIBUTING.md.
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.
Rationale for this change
Fixes #1344.
Value.Value()built a long-form string withunsafe.String(&v.value[5], sz). For an empty string the encoded value is only the 5-byte header and length, so&v.value[5]was out of range and it panicked.String()andMarshalJSON()go throughValue()and panicked the same way.validatePrimitiveValueaccepts the encoding, sovariant.Newreturns the value without an error.What changes are included in this PR?
The
PrimitiveStringbranch now returns""when the length is zero, the same guard the short-string branch already has.Are these changes tested?
Yes.
TestLongFormStringbuilds the 5-byte encoding from the issue and a non-empty long-form string, and checksType(),Value()andString()for both. The empty case panics on main withindex out of range [5] with length 5and passes with the fix.go test ./parquet/...passes (with the testing submodules), as do the other packages that importparquet/variant(arrow/compute,arrow/extensions,parquet/pqarrow). golangci-lint v2.13.2 reports no issues.Are there any user-facing changes?
An empty string in the long-form encoding now reads as
""instead of panicking.