Skip to content

Some error types don't match the specs #306

Open

Description

@twuebi
  • NamespaceNotFound -> NoSuchNamespaceException (causes 404 on namespace not found on POST table to become a NoSuchTableException in java due to:
    @Override
    public void accept(ErrorResponse error) {
      switch (error.code()) {
        case 404:
          if (NoSuchNamespaceException.class.getSimpleName().equals(error.type())) {
            throw new NoSuchNamespaceException("%s", error.message());
          } else {
            throw new NoSuchTableException("%s", error.message());
          }
        case 409:
          throw new AlreadyExistsException("%s", error.message());
      }

      super.accept(error);
    }
  }

Activity

  1. added
    bug
    good first issue
    on Aug 28, 2024
  2. ndrluis commented on Aug 1, 2025

    @ndrluis
    Contributor

    Hello @twuebi, could you elaborate on what the problem is with Lakekeeper? I'm a bit confused about the issue.

  3. twuebi commented on Aug 1, 2025

    @twuebi
    CollaboratorAuthor

    Hi @ndrluis, it's been a while, I think I created this issue after running the rest compatibility suite of the Java iceberg repo against lakekeeper. A lot of their tests were failing but not due to functional problems but due to the error code not matching what Java would expect.

    Lakekeeper could try to align itself with what the test suite expects. In some cases it wouldn't make a difference in others it makes a difference in what exception a client will see which can or cannot be misleading.

    I think in the example above, trying to read a table from a non-existing namespace will produce a table does not exist error instead of a name space does not exist error due to error code not matching the Java expectation.

  4. ndrluis commented on Aug 4, 2025

    @ndrluis
    Contributor

    In some tests, I got this kind of error that I don't know if it makes sense to fix, like these. @twuebi @c-thiel @mooori what do you think about these tests?

    Iceberg REST Compatibility Kit > JUnit Jupiter > RESTCompatibilityKitViewCatalogTests > renameTableTargetAlreadyExistsAsView() FAILED
        java.lang.AssertionError:
        Expecting throwable message:
          "Error renaming Table"
        to contain:
          "Cannot rename ns.table to ns.view. View already exists"
    
    Iceberg REST Compatibility Kit > JUnit Jupiter > RESTCompatibilityKitViewCatalogTests > updateViewLocationConflict() FAILED
        java.lang.AssertionError:
        Expecting throwable message:
          "View not found or action can_get_metadata forbidden for Principal(oidc~9410d0bf-4487-4177-a34f-af364cac0a59)"
        to contain:
          "View does not exist: ns.view"
    

    I got some errors that returned a NotAuthorized exception, and this seems really strange to me. I will list all the cases that returned "Not authorized" and try to implement the tests on the Lakekeeper side to reproduce them.

    Iceberg REST Compatibility Kit > JUnit Jupiter > RESTCompatibilityKitCatalogTests > testConcurrentReplaceTransactionSortOrderConflict() FAILED
        org.apache.iceberg.exceptions.NotAuthorizedException: Not authorized: Failed to authenticate
            at app//org.apache.iceberg.rest.ErrorHandlers$DefaultErrorHandler.accept(ErrorHandlers.java:234)
            at app//org.apache.iceberg.rest.ErrorHandlers$DefaultErrorHandler.accept(ErrorHandlers.java:212)
            at app//org.apache.iceberg.rest.HTTPClient.throwFailure(HTTPClient.java:215)
            at app//org.apache.iceberg.rest.HTTPClient.execute(HTTPClient.java:299)
            at app//org.apache.iceberg.rest.BaseHTTPClient.post(BaseHTTPClient.java:100)
            at app//org.apache.iceberg.aws.s3.signer.S3V4RestSignerClient.sign(S3V4RestSignerClient.java:256)
    

    Here are the results of the RCK run (https://gist.github.com/ndrluis/c2869d7f032808461fd51bde5182f8ee)

    For the case of NamespaceNotFound -> NoSuchNamespaceException, I will open a PR in the next few days.

  5. ndrluis commented on Aug 4, 2025

    @ndrluis
    Contributor

    I ran another test with the minimal setup (without Authentication), and here are the results (https://gist.github.com/ndrluis/f805f0aa41dfba05441e1b91164b59f3). So when we have AuthN enabled, we receive a NotAuthorized error instead of the requirement error. I will open a new issue for this case, as we have some other cases that I think we need to understand to determine if it's a problem in the Lakekeeper.

    About the text in the requirement exception, I know that it's a problem on the iceberg-rust side. I will open a discussion on the Iceberg Mailing list because if we want to use the RCK to test any REST implementation, we need to follow the same error message in all clients, or we need to rewrite the RCK tests to be more permissive

  6. ndrluis commented on Aug 5, 2025

    @ndrluis
    Contributor
  7. ndrluis commented on Aug 8, 2025

    @ndrluis
    Contributor

    I opened this PR #1278 to solve the issue reported here. However, I will open other PRs with the RCK setup and some fixes. I believe we can change the scope of this issue to be broader in order to solve the incompatibility with the spec.

  8. Sahan-Chathumina-25 commented on Sep 28, 2026

    @Sahan-Chathumina-25

    Analysis:

    Issue #306 — Some error types don't match the specs

    I looked into the NamespaceNotFound -> NoSuchNamespaceException case described here (a 404 on a missing namespace surfacing as NoSuchTableException in the Java client because it keys off error.type).

    Current state in this checkout:

    • NamespaceNotFound already maps to type: "NoSuchNamespaceException" with code 404 (crates/lakekeeper/src/service/catalog_store/namespace.rs).
    • The authz layer preserves that type for the not-found case (crates/lakekeeper/src/service/authz/namespace.rs — AuthZCannotSeeNamespace / AuthZCannotSeeAnonymousNamespace).
    • Table create (server/tables/create_table.rs via load_and_authorize_namespace_action) fails on the missing namespace before any table work, so POST /namespaces/{ns}/tables against a missing namespace returns NoSuchNamespaceException.
    • Table load by ident (service/authz/table.rs::load_and_authorize_table_operation) fetches warehouse/namespace/table in parallel and checks namespace presence before table presence, so a load in a missing namespace returns NoSuchNamespaceException, not NoSuchTableException.
    • Rename to a missing namespace is covered by an existing test asserting 404 + NoSuchNamespaceException (crates/lakekeeper-integration-tests/tests/server_tables_postgres.rs).

    So the narrow example from the original report looks addressed in the current code. The earlier attempted fix in #1278 was closed unmerged, and its concerns (rename authz gating, 403-vs-404 mapping) have since moved on.

    Why I'm not changing anything in this pass:

    The remaining scope on this issue is the broader REST Compatibility Kit alignment from the later comments: exact type strings per endpoint, error message wording across clients (Java vs Rust), NotAuthorized vs requirement errors when authn is enabled, and view/rename edge cases. That is a matrix decision, not a single low-risk edit — it touches the deliberate 404-vs-403 ambiguity in the authz layer, the OpenAPI rest-catalog-open-api.yaml descriptions, and client expectations, and the right verification is a full RCK run (Java harness + live server), which I can't do reliably here.

    Suggested approach:

    1. Run the Iceberg REST Compatibility Kit against a minimal (no-auth) Lakekeeper and capture the current failure list (the old gists in this thread have expired).
    2. Triage per endpoint: for each mismatch, decide the spec-correct type + code from the REST OpenAPI spec (e.g. NoSuchNamespaceException vs NoSuchTableException vs NoSuchViewException on load/create/rename/drop), separate from message-text differences that belong in the clients/RCK.
    3. File small per-endpoint fixes with integration tests asserting error.type + code, keeping the authz information-hiding behavior intact; handle the auth-enabled NotAuthorized masking as its own issue.

    No tracked files changed.

    No changes were proposed for now.

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    buggood first issue

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions