zhang-arvin opened a new pull request, #13722:
URL: https://github.com/apache/gravitino/pull/13722
{"title": "[#13696] fix(lance): validate dataset location before registering
tables", "head": "zhang-arvin:fix-13696-lance-location-validation", "base":
"main", "body": "### What changes were proposed in this pull request?\n\nLance
table operations accepted caller-supplied locations without validating that
they resolve to a valid Lance dataset before storage I/O (issue
#13696).\n\n`RegisterTable` stores the supplied location verbatim. A later
Lance REST `drop` calls `purgeTable`, which passes that location to
`Dataset.drop` -- so an unrelated directory registered as a table location
could be removed.\n\nThis change validates the location before recording table
metadata in the register path (`LanceTableOperations.createTableInternal` when
`lance.register=true`): the dataset is opened first, and if it does not resolve
to a valid Lance dataset the operation fails fast with a clear
`IllegalArgumentException` instead of persisting a location that could later be
purged.\n\n### Why are t
he changes needed?\n\nPrevents registering a non-Lance directory as an
external table and subsequently deleting unrelated data via drop/purge.\n\n###
Does this PR introduce _any_ user-facing change?\n\nYes: registering a Lance
table with a location that is not a valid Lance dataset now returns an error
(mapped to `InvalidInputException` -> HTTP 400 through the Lance REST
`LanceExceptionMapper`) instead of succeeding.\n\n### How was the test
done?\n\nAdded unit tests in `TestLanceTableOperations`:\n- register with a
location that fails to open as a Lance dataset -> `IllegalArgumentException`,
no metadata written;\n- register with a blank location ->
`IllegalArgumentException`, no metadata written;\n- register with a location
that opens as a valid dataset -> table metadata written.\n\nRan `./gradlew
:catalogs:catalog-lakehouse-generic:test --tests
org.apache.gravitino.catalog.lakehouse.lance.TestLanceTableOperations` (green)
and `./gradlew :catalogs:catalog-lakehouse-generic:spotlessA
pply`.\n\n### Was this patch authored or co-authored using generative AI
tooling?\n\nYes.\n\nFixes #13696"}
--
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]