Skip to content

Conversation

@gabeiglio
Copy link
Contributor

@gabeiglio gabeiglio commented Aug 30, 2025

Rationale for this change

Error handling differed with the Java implementation in the following:

  • 404 errors for tables or view can be NoSuchNamespaceError if the namespace does not exists (same as Java)
  • table commit will use the table error handler (instead of the commit error handler) if the commit will create a table (staged create)
  • Created ViewAlreadyExistsError for completeness even though we don't support creating views atm
  • Additionally this PR marks commit 503 errors as CommitStateUnkown as changed recently in Java

Are these changes tested?

Added two unit tests for testing the exception thrown between NoSuchNamespaceError and NoSuchTableError

Are there any user-facing changes?

No

@gabeiglio gabeiglio marked this pull request as ready for review August 30, 2025 21:27
@jayceslesar
Copy link
Contributor

more of a meta question but I wonder if we could auto generate some testing based off of the openapi spec upstream?

Copy link
Contributor

@geruh geruh left a comment

Choose a reason for hiding this comment

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

Overall, this looks good to me!!

There is a lot of refactoring here, and it centralizes all of the error handling into one place, which makes it easier to add new exceptions as they come from upstream. As we can see with this ViewAlreadyExistsError you added.

If there isn't a good way to test with the current rest catalog tests, maybe it would be good to add some additional unit tests. For example, NamespaceNotEmpty is properly handled instead of throwing a BadRequestError Or same for like the table and namespace already exists handling.

WDYT

assert "Table does not exist" in str(e.value)


def test_load_table_404_non_existent_namespace(rest_mock: Mocker) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

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

The mocked tests predate the time when we didn't have the IcebergTestFixtures Docker image. I think it would be best to test against the Docker image instead in the integration tests.

@Fokko
Copy link
Contributor

Fokko commented Dec 1, 2025

Thanks @gabeiglio for working on this, and thanks @geruh for bringing this back up in my mailbox :) I agree with what Drew is saying, but in general, I think this is a great improvement 👍 Could you follow up, so we can get this in?

Copy link
Contributor

@geruh geruh left a comment

Choose a reason for hiding this comment

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

This looks good to me! Just have the one comment below

)

with pytest.raises(NoSuchNamespaceError) as e:
RestCatalog("rest", uri=TEST_URI, token=TEST_TOKEN).drop_table(("fokko", "does_not_exists"))
Copy link
Contributor

Choose a reason for hiding this comment

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

lol

Copy link
Contributor

@geruh geruh left a comment

Choose a reason for hiding this comment

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

Awesome thanks for this @gabeiglio!

@gabeiglio
Copy link
Contributor Author

@Fokko bringing this back up to your mailbox :)

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.

4 participants