[#12468] fix(lance): validate the identifier in ListNamespaces at schema level - #12469
Open
FANNG1 wants to merge 1 commit into
Open
[#12468] fix(lance): validate the identifier in ListNamespaces at schema level#12469FANNG1 wants to merge 1 commit into
FANNG1 wants to merge 1 commit into
Conversation
…at schema level ListNamespaces returned an empty list for any two-level identifier without checking that the catalog and schema exist, so a nonexistent path was reported as an existing but empty namespace while its own one-level prefix correctly failed. Validate the catalog and the schema before returning the (correctly) empty list, reusing the helper that namespaceExists already uses. Claude-Session: https://claude.ai/code/session_012J3xbmJ3pHcMuJfG7Sonr6
Code Coverage Report
Files
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What changes were proposed in this pull request?
GravitinoLanceNameSpaceOperations.listNamespacesnow validates the identifierin its two-level branch: it resolves the catalog with
loadAndValidateLakehouseCatalogand checks the schema withschemaExistsbefore returning the empty list. The schema check shared with
namespaceExistsis extracted into a
validateSchemaExistshelper so both operations raise thesame
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?
ListNamespacesreturned HTTP 200 with{"namespaces":[]}for any two-levelidentifier, 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:
listNamespaceswas also the only namespace operation without this check —describeNamespace,namespaceExists,dropNamespaceandcreateNamespaceall validate at level 2. Clients that probe a configured namespace path with
ListNamespaces(for example Apache Doris's Lance REST catalog, which probeslance.namespace.parentat catalog-creation time) silently accepted a mistypedschema and only failed much later on the first read.
ListTableswas checked for the mirror-image gap and does not have one: itrequires exactly two levels, and
ManagedTableOperations.listTablesthrowsNoSuchSchemaExceptionfor a nonexistent schema, which the exception mapperturns into a 404.
Fix: #12468
Does this PR introduce any user-facing change?
Yes.
ListNamespaceson a two-level identifier whose catalog or schema does notexist now returns 404
NAMESPACE_NOT_FOUNDinstead of 200 with an empty list.Listing a schema that does exist still returns an empty list as before.
How was this patch tested?
TestGravitinoLanceNameSpaceOperations(3 cases: existingschema 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.
LanceRESTServiceIT.testListNamespacesto cover the same threecases end to end against a running Lance REST service; passes.
./gradlew :lance:lance-common:test :lance:lance-rest-server:test -PskipITspasses.
https://claude.ai/code/session_012J3xbmJ3pHcMuJfG7Sonr6