Skip to content

fix(arrow/array): validate map builder entry lengths#957

Open
fallintoplace wants to merge 1 commit into
apache:mainfrom
fallintoplace:fix/map-builder-length-validation
Open

fix(arrow/array): validate map builder entry lengths#957
fallintoplace wants to merge 1 commit into
apache:mainfrom
fallintoplace:fix/map-builder-length-validation

Conversation

@fallintoplace

Copy link
Copy Markdown
Contributor

Rationale for this change

MapBuilder currently sizes its child struct from the key builder without checking the item builder. Unequal key and item counts can therefore create malformed map data or defer the failure until later array access.

What changes are included in this PR?

  • Reject unequal key and item builder lengths before array construction resets the builders.
  • Reject a child struct length that exceeds the entry count.
  • Validate the offset count and any explicitly supplied final offset.
  • Return invariant failures as panics wrapping arrow.ErrInvalid, consistent with the existing builder API.

Are these changes tested?

Yes. Tests cover extra keys, extra items, an oversized child struct, and a final offset that exceeds the available entries. The array subtree tests, focused race tests, 10 repeated package runs, and linux/amd64 compilation pass.

Are there any user-facing changes?

Malformed map builder state now fails immediately with a descriptive invalid-data panic instead of constructing an inconsistent array or panicking during later access. Valid builder usage is unchanged.

@fallintoplace fallintoplace requested a review from zeroshade as a code owner July 16, 2026 12:59
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.

1 participant