Skip to content

fix: guard against null metadata in checkCurrentMetadataLocation - #17548

Open
waterWang wants to merge 1 commit into
apache:mainfrom
waterWang:fix/check-metadata-npe-17462
Open

fix: guard against null metadata in checkCurrentMetadataLocation#17548
waterWang wants to merge 1 commit into
apache:mainfrom
waterWang:fix/check-metadata-npe-17462

Conversation

@waterWang

Copy link
Copy Markdown

Description

When checkCommitStatus is called during a CREATE TABLE operation (where base == null), refresh() returns null because the table does not yet exist in the metastore. The subsequent call to metadata.metadataFileLocation() throws a NullPointerException, which is swallowed by .suppressFailureWhenFinished(), resulting in a misleading CommitStateUnknownException that tells the user to perform unnecessary manual remediation.

Fix

Add a null check after refresh(). If refresh() returns null, the table does not exist in the catalog, so the commit could not have landed — return false immediately.

Root cause

HiveTableOperations.doRefresh() swallows NoSuchObjectException when currentMetadataLocation() is null (the CREATE TABLE case), leaving currentMetadata == null with shouldRefresh = false. The subsequent refresh()current() call returns null, which checkCurrentMetadataLocation then dereferences.

Testing

The existing test coverage for checkCommitStatus only covers the update path (table already exists). A CREATE TABLE failure path is not covered by TestHiveCommits. This fix adds a defensive null guard that is trivially correct — the only valid return value when the table metadata is null is false (commit did not land).

Closes #17462

@github-actions github-actions Bot added the core label Aug 7, 2026

@uros-b uros-b 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.

@waterWang Please note that @superdiaodiao was already working on this in #17464.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hive: NullPointerException in checkCommitStatus when CREATE TABLE commit fails, masking FAILURE as CommitStateUnknownException

2 participants