FANNG1 opened a new pull request, #12469:
URL: https://github.com/apache/gravitino/pull/12469

   ### What changes were proposed in this pull request?
   
   `GravitinoLanceNameSpaceOperations.listNamespaces` now validates the 
identifier
   in its two-level branch: it resolves the catalog with
   `loadAndValidateLakehouseCatalog` and checks the schema with `schemaExists`
   before returning the empty list. The schema check shared with 
`namespaceExists`
   is extracted into a `validateSchemaExists` helper so both operations raise 
the
   same `NamespaceNotFoundException`.
   
   Returning an empty list at level 2 stays correct — a schema has no child
   namespaces, only tables — the missing part was the existence check.
   
   ### Why are the changes needed?
   
   `ListNamespaces` returned HTTP 200 with `{"namespaces":[]}` for any two-level
   identifier, without checking that it referred to anything real. That made a
   child of a nonexistent parent look like it existed, while the parent itself
   correctly failed:
   
       GET /lance/v1/namespace/BOGUS_CATALOG%24BOGUS_SCHEMA/list?delimiter=%24
       {"namespaces":[]}                                    <-- success
   
       GET /lance/v1/namespace/BOGUS_CATALOG/list?delimiter=%24
       {"error":"Catalog not found: BOGUS_CATALOG", ...}    <-- correctly fails
   
   `listNamespaces` was also the only namespace operation without this check —
   `describeNamespace`, `namespaceExists`, `dropNamespace` and `createNamespace`
   all validate at level 2. Clients that probe a configured namespace path with
   `ListNamespaces` (for example Apache Doris's Lance REST catalog, which probes
   `lance.namespace.parent` at catalog-creation time) silently accepted a 
mistyped
   schema and only failed much later on the first read.
   
   `ListTables` was checked for the mirror-image gap and does not have one: it
   requires exactly two levels, and `ManagedTableOperations.listTables` throws
   `NoSuchSchemaException` for a nonexistent schema, which the exception mapper
   turns into a 404.
   
   Fix: #12468
   
   ### Does this PR introduce _any_ user-facing change?
   
   Yes. `ListNamespaces` on a two-level identifier whose catalog or schema does 
not
   exist now returns 404 `NAMESPACE_NOT_FOUND` instead of 200 with an empty 
list.
   Listing a schema that does exist still returns an empty list as before.
   
   ### How was this patch tested?
   
   - New unit test `TestGravitinoLanceNameSpaceOperations` (3 cases: existing
     schema returns an empty list; nonexistent schema returns 404; nonexistent
     catalog returns 404 at both one and two levels). Reverting the main-code
     change makes 2 of the 3 fail.
   - Extended `LanceRESTServiceIT.testListNamespaces` to cover the same three
     cases end to end against a running Lance REST service; passes.
   - `./gradlew :lance:lance-common:test :lance:lance-rest-server:test 
-PskipITs`
     passes.
   
   https://claude.ai/code/session_012J3xbmJ3pHcMuJfG7Sonr6
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to