Skip to content

[Server] Report an unreadable table metadata file as the failure it is - #1845

Merged
yili-db merged 2 commits into
unitycatalog:mainfrom
moomindani:fix/iceberg-unreadable-metadata
Sep 14, 2026
Merged

yili-db merged 2 commits into
unitycatalog:mainfrom
moomindani:fix/iceberg-unreadable-metadata

Conversation

@moomindani

Copy link
Copy Markdown
Contributor

PR Checklist

  • A description of the changes is added to the description of this PR.
  • If there is a related issue, make sure it is linked to this PR.
  • If you've fixed a bug or added code that should be tested, add tests!
  • If you've added or modified a feature, documentation in docs is updated

Description of changes

Fixes #1841.

A table the catalog lists whose metadata file cannot be read came back as a 500 typed
NotFoundException, with the file reader's message and the path the server keeps the file at. Iceberg
raises that exception for any file a table points at, and this handler had no case for it, so the
status came from the internal error the request became while the type came from the cause.

IcebergRestExceptionHandler now answers it as a service failure, which is what the 500 already said,
with a message that says the table's Iceberg metadata could not be read. The original failure stays as
the cause, so the server's own logs still name the file and the reason.

For users: a client can tell "this table is gone" from "this server could not read this table", which
the previous response conflated, and the storage path no longer reaches the client.

testLoadTableWhoseMetadataCannotBeRead deletes the metadata file of a registered table and pins the
500, the ServiceFailureException type and the absence of the table's location from the message. It
fails on an unfixed tree and passes with the fix; the full server/test suite shows no failure
attributable to this change.

@yili-db

yili-db commented Sep 7, 2026

Copy link
Copy Markdown
Collaborator

Wait for #1797 to get in first.

@moomindani
moomindani force-pushed the fix/iceberg-unreadable-metadata branch from 4c1be22 to a87a641 Compare September 10, 2026 00:56
@moomindani

Copy link
Copy Markdown
Contributor Author

Rebased onto 4ee2b248. Still waiting on #1797, as you asked.

@moomindani
moomindani force-pushed the fix/iceberg-unreadable-metadata branch from a87a641 to a38b03d Compare September 11, 2026 01:30
@moomindani

Copy link
Copy Markdown
Contributor Author

Rebased onto 81663d1f, now that #1797 is in.

if (cause instanceof BadRequestException) {
return wrapException(ErrorCode.INVALID_ARGUMENT, cause);
}
if (cause instanceof NotFoundException) {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This error from Iceberg is thrown for any file not found. Today only table metadata error can be triggered. But this is not future proof.
The error message can be weakened as "Could not read this table" instead.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Weakened to "Could not read this table", and the comment now says why: Iceberg raises this for any file, today only a table's metadata file reaches here, and naming that file would make the message wrong as soon as another read raises it.

assertThat(error.code()).isEqualTo(500);
assertThat(error.type()).isEqualTo(ServiceFailureException.class.getSimpleName());
// Where the server keeps the file is not the client's business.
assertThat(error.message()).doesNotContain(icebergTableLocation.toString());

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Please also assert on the mesage text.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Added -- the test now asserts the message is exactly "Could not read this table", alongside the existing check that it does not quote the server's storage path.

A table the catalog lists whose metadata file cannot be read came back as a 500 typed
"NotFoundException", with the message Iceberg's file reader produced: "Failed to read file:" and the
path the server keeps the file at. Iceberg raises that exception for any file a table points at, and
this handler had no case for it, so the status came from the internal error the request became while
the type came from the cause. The two contradict each other: a client reads a not-found type as
something it can act on -- the table it asked for is gone -- when the table is there and the server
could not read it.

Report it as a service failure instead, which is what the 500 already said, and say that the table's
Iceberg metadata could not be read rather than quoting the reader and the location. The original
failure stays as the cause, so the server's own logs still name the file.

Signed-off-by: Noritaka Sekiyama <[email protected]>
Review follow-up. Iceberg raises NotFoundException for any file it cannot read;
today only a table's metadata file reaches this handler, but naming that file in
the message makes the answer wrong the moment another read starts raising it.
Name the table instead, and pin the message in the test.

Signed-off-by: Noritaka Sekiyama <[email protected]>
@moomindani
moomindani force-pushed the fix/iceberg-unreadable-metadata branch from 649b51b to 5956f6f Compare September 14, 2026 01:46
@yili-db
yili-db merged commit 2b57e36 into unitycatalog:main Sep 14, 2026
16 checks passed
yili-db added a commit to moomindani/unitycatalog that referenced this pull request Sep 14, 2026
- Resolve conflict in `IcebergRestCatalogTest`, keeping both sides' new tests:
  - this PR's `testListNamespacesUnderAParent` and `testReportMetricsRejectsAnUnreadableBodyWithoutLeakingTheParser`
  - main's `testLoadTableWhoseMetadataCannotBeRead` (unitycatalog#1845)

Signed-off-by: Yi Li <[email protected]>
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.

Iceberg REST answers an unreadable metadata file with a 500 typed NotFoundException

2 participants