Skip to content

fix(table): validate required metadata identity fields - #1867

Merged
zeroshade merged 1 commit into
apache:mainfrom
Revanth14:fix/table-metadata-required-identity-fields
Aug 26, 2026
Merged

fix(table): validate required metadata identity fields#1867
zeroshade merged 1 commit into
apache:mainfrom
Revanth14:fix/table-metadata-required-identity-fields

Conversation

@Revanth14

Copy link
Copy Markdown
Contributor

Description

This PR validates required identity fields when parsing table metadata:

  • Rejects missing, null, or empty location for format versions 1–3.
  • Rejects missing, null, or zero-valued table-uuid for format versions 2–3.
  • Preserves v1 compatibility by allowing an absent table-uuid.
  • Fixes v1-to-v2 conversion so a UUID is generated when the v1 metadata has no UUID.
  • Updates affected test fixtures to contain valid required fields.

Validation is performed at the JSON parsing boundary rather than in the shared metadata validator. This keeps the existing create-via-commit staging flow valid, where metadata may temporarily have an empty location before it is persisted.

Why are these changes needed?

Previously, invalid table metadata was silently accepted:

  • A missing location became "".
  • A missing UUID became uuid.Nil.

This could cause location providers to produce bogus relative paths and could make assert-table-uuid requirements incorrectly match unrelated UUID-less tables.

The behavior now matches the Iceberg requirements for the currently supported format versions. Two deliberate deltas from Java: "location": "" and an explicitly all-zeros table-uuid are rejected here, where Java only checks for null. Both are covered by tests. If format v4 support is added, location validation will need to account for location becoming optional.

Note: this is a behavior change. Metadata that previously parsed successfully may now return an error.

Real-world compatibility risk is limited:

  • Normal table creation generates a UUID through NewMetadata.
  • Builder-based v1-to-v2/v3 upgrades assign a UUID through SetFormatVersion.
  • Create-via-commit temporarily constructs metadata with an empty location, but supplies the actual location through an update before persistence.

Malformed externally produced metadata and the direct v1-to-v2 conversion path are the primary cases affected. This behavior change may warrant a release note.

Tests

Added coverage for:

  • Missing, null, and empty locations across v1–v3.
  • Missing, null, and zero UUIDs across v2–v3.
  • v1 compatibility for absent UUIDs.
  • UUID generation during v1-to-v2 conversion.
  • Successful reparsing of converted metadata.

Validated with:

  • go test ./... -count=1
  • go vet -tags=integration ./...

Closes #1864

@Revanth14
Revanth14 requested a review from zeroshade as a code owner August 23, 2026 10:27

@zeroshade zeroshade 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.

LGTM, just need to rebase onto main to pick up the linting fixes

@Revanth14
Revanth14 force-pushed the fix/table-metadata-required-identity-fields branch from 4f36a14 to 3469104 Compare August 25, 2026 17:01
@Revanth14

Copy link
Copy Markdown
Contributor Author

LGTM, just need to rebase onto main to pick up the linting fixes

@zeroshade
Rebase done and CI is green!

@zeroshade
zeroshade merged commit e8023b8 into apache:main Aug 26, 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.

Table metadata parser accepts missing required location and v2/v3 table UUID

2 participants