Skip to content

[iceberg] Fix NPE in IcebergRestMetadataCommitter when table has no snapshots#7688

Merged
JingsongLi merged 1 commit into
apache:masterfrom
JTaky:fix-iceberg-rest-npe
Apr 24, 2026
Merged

[iceberg] Fix NPE in IcebergRestMetadataCommitter when table has no snapshots#7688
JingsongLi merged 1 commit into
apache:masterfrom
JTaky:fix-iceberg-rest-npe

Conversation

@JTaky
Copy link
Copy Markdown
Contributor

@JTaky JTaky commented Apr 22, 2026

Motivation

When committing Iceberg metadata via the REST catalog, commitMetadataImpl takes the !withBase code path if the base metadata check fails.
In this path, a log statement calls currentSnapshot().snapshotId() on both the existing and new table metadata. However, currentSnapshot() returns null when a table exists but has no snapshots (e.g., a freshly created or empty table), causing a NullPointerException that fails the entire commit. Since it happens only for an empty iceberg table, we can manually delete the table and be unblocked.

Meanwhile we should not have NPE in the log method.

Caused by: java.lang.NullPointerException
    at org.apache.paimon.iceberg.IcebergRestMetadataCommitter.commitMetadataImpl(IcebergRestMetadataCommitter.java:161)

Implementation

Added null guards for metadata.currentSnapshot() and newMetadata.currentSnapshot() in the log statement, logging "No snapshot" when the snapshot is absent.

…napshots

currentSnapshot() can return null for tables that exist but have no
snapshots yet. The log statement in commitMetadataImpl did not handle
this case, causing a NullPointerException.
@JTaky JTaky marked this pull request as ready for review April 23, 2026 08:45
@JingsongLi
Copy link
Copy Markdown
Contributor

+1 Thanks @JTaky

@JingsongLi JingsongLi merged commit e5214cc into apache:master Apr 24, 2026
12 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.

2 participants