Skip to content

fix(manifest): validate struct child lengths - #1054

Merged
wgtmac merged 2 commits into
apache:mainfrom
gty404:fix/manifest-children-length
Oct 28, 2026
Merged

wgtmac merged 2 commits into
apache:mainfrom
gty404:fix/manifest-children-length

Conversation

@gty404

@gty404 gty404 commented Oct 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Add ValidateStructLength, which verifies every child of a struct view has the same logical length as its parent.
  • Apply the check at the manifest-list, manifest-entry, data-file, and partition parsing boundaries before writing into parent-sized containers.
  • Use ICEBERG_CHECK to fail closed if a non-canonical Arrow batch reaches the parser.

Why

The built-in Avro manifest reader produces canonical, equal-length struct batches. This validation is defensive hardening for unexpected reader output rather than support for a new input path.

Test plan

  • pre-commit run --files src/iceberg/manifest/manifest_reader.cc src/iceberg/test/manifest_reader_test.cc
  • cmake --build build --target manifest_test -j2
  • build/src/iceberg/test/manifest_test (226 passed, 18 skipped)

nanoarrow FULL validation only requires a struct's children to be at
least as long as the parent, but ParseManifestList/ParseDataFile/
ParseManifestEntry index containers sized by the parent's row count
using each child's own length. A spec-legal batch with a longer child
would drive those parsers past the end of the output vector.

Add AssertChildrenLength and call it everywhere a struct's children
feed a parent-sized container, including the partition struct case
which previously skipped the children-count check entirely.
Comment thread src/iceberg/manifest/manifest_reader.cc Outdated
Use ValidateStructLength at parent-sized manifest parser boundaries. The built-in Avro reader produces canonical batches, so this is defensive validation rather than a supported malformed-input path.
@wgtmac wgtmac changed the title fix(manifest): reject struct children longer than their parent length fix(manifest): validate struct child lengths Oct 28, 2026

@wgtmac wgtmac left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this PR fixes a real issue. The manifest reader only reads Arrow arrays from our own Avro reader, so child lengths always match. If this can ever happen (i.e. users have registered their own Avro readers), it is only a defensive case. I simplified the check to ValidateStructLength. I also removed the test because it covered an unreachable case and did not test a useful production path.

@wgtmac
wgtmac merged commit 83c41e4 into apache:main Oct 28, 2026
15 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.

3 participants