fix!: guard remote index routes against dot segments (#5013)

BREAKING CHANGE: Older Enterprise index listings that require per-index
statistics now omit historical entries with empty names, `.` or `..`.
Remote index operations reject these unaddressable names. Operators
needing to remove such entries can use server-side maintenance; direct
native access also supports cleanup. Ordinary index names and
`exist_ok=True` reuse require no migration.

Fixes #5007

Remote index URLs previously allowed `.` and `..` as path segments.
Reqwest normalizes them, so dropping an index named `..` could send the
table-level drop request and delete the table.

Guard the remote statistics, prewarm, and drop routes against empty
names, `.` and `..`, then percent-encode all other names. Index creation
retains its existing name policy on both backends, including names such
as `Customer lookup` and `café_idx` and reuse through `exist_ok=True`.
The same remote guard applies on checked-out branches.

Enriched Enterprise listings retain these entries without issuing stats
requests. Native cleanup is covered by a regression test. API
documentation explains these limits, and website release guidance
remains a non-rendering draft.

Validation:

- Before the review fix, 12 of 15 focused regressions failed,
reproducing valid-name rejection, generated-name reuse failure, and
mixed legacy-list failure.
- 60 focused Rust tests passed, covering unsafe routes, encoded names,
mixed legacy/enriched listings, generated names, native and Enterprise
lifecycles, checked-out branches, and `exist_ok` preservation of index
identity, definition, and table version.
- Rebuilt the Python extension in the uv-managed environment from
`python/uv.lock`; all 28 targeted Python tests passed, including both
names and synchronous/asynchronous `exist_ok` reuse.
- Node native build, TypeScript type checking, lint/format checks, four
targeted index tests, and generated API documentation passed.
- Rust formatting, Clippy (`remote`, tests and examples), Python
formatting/lint, repository-wide Typos 1.26.0, and `git diff --check`
passed. Native builds used the repository `ci` profile with
`remote,lancedb/metrics-otel` enabled for Python and Node.
- Repository-root Ruff lint reports 59 existing errors in unchanged
`docs/web-tests`; Python-package lint passes.

<!-- lance-gatekeeper-fix:v1 agent=1ef05de7bc00306ccd6f8a60b9a81003
generation=1 -->

<!-- gatefixer-walkthrough:v1
head=6b25e10810ea1d11a4ef56be63c4ef50225f65d6 -->
## Change walkthrough

```mermaid
flowchart TD
    entry["Listed index"] --> typed{"Type available?"}
    typed -->|Yes| include["Include index"]
    typed -->|No| safe{"Addressable name?"}
    safe -->|No| omit["Omit entry"]
    safe -->|Yes| stats["Encode and fetch stats"]
    stats --> include
```

Creation preserves existing name support; remote routes reject only
empty names, `.` and `..`.

**Read:** [Route
guard](https://github.com/lancedb/lancedb/blob/6b25e10810ea1d11a4ef56be63c4ef50225f65d6/rust/lancedb/src/remote/table.rs#L102-L112)
→ [Listing
fallback](https://github.com/lancedb/lancedb/blob/6b25e10810ea1d11a4ef56be63c4ef50225f65d6/rust/lancedb/src/remote/table.rs#L2534-L2596)
→ [Index-preservation
regression](https://github.com/lancedb/lancedb/blob/6b25e10810ea1d11a4ef56be63c4ef50225f65d6/rust/lancedb/src/table/create_index.rs#L1431-L1481).

<sub>Snapshot:
[6b25e10](https://github.com/lancedb/lancedb/commit/6b25e10810ea1d11a4ef56be63c4ef50225f65d6)</sub>
<!-- gatefixer-walkthrough:end -->

---------

Co-authored-by: Gatefixer <313497061+lancedb-gatefixer[bot]@users.noreply.github.com>
This commit is contained in:
lancedb-gatefixer[bot]
2026-11-30 20:51:19 +08:00
committed by GitHub
parent 97c88659f4
commit d9db83de65
10 changed files with 472 additions and 59 deletions
+18
View File
@@ -2315,6 +2315,11 @@ class Table(ABC):
Use [list_indices][lancedb.table.Table.list_indices] to find the names of
the indices.
Remote tables reject empty names, ``.`` and ``..`` to prevent URL path
normalization. Existing indices named ``.`` or ``..`` require server-side
cleanup on managed tables, or a native connection with direct access to
the dataset. Other existing and generated names remain addressable.
"""
raise NotImplementedError("drop_index is not supported for this table type")
@@ -3471,6 +3476,10 @@ class Table(ABC):
List all indices that have been created with
[Table.create_index][lancedb.table.Table.create_index]
On older Enterprise servers, this method omits indices named ``.``,
``..`` or the empty string because their statistics cannot be requested
safely.
On LanceDB Enterprise tables, an index whose build hasn't finished may
be missing (vector indices) or listed with 0 indexed rows (scalar and
FTS indices), and ``num_unindexed_rows`` may be ``None``. Use
@@ -8249,6 +8258,11 @@ class AsyncTable:
Use [list_indices][lancedb.table.AsyncTable.list_indices] to find the names
of the indices.
Remote tables reject empty names, ``.`` and ``..`` to prevent URL path
normalization. Existing indices named ``.`` or ``..`` require server-side
cleanup on managed tables, or a native connection with direct access to
the dataset. Other existing and generated names remain addressable.
"""
await self._inner.drop_index(name)
@@ -10596,6 +10610,10 @@ class AsyncTable:
"""
List all indices that have been created with Self::create_index
On older Enterprise servers, this method omits indices named ``.``,
``..`` or the empty string because their statistics cannot be requested
safely.
On LanceDB Enterprise tables, an index whose build hasn't finished may
be missing (vector indices) or listed with 0 indexed rows (scalar and
FTS indices), and ``num_unindexed_rows`` may be ``None``. Use
+24
View File
@@ -1176,3 +1176,27 @@ async def test_named_index_exist_ok_checks_before_column_validation(
await result.wait()
assert await some_table.version() == version
assert [index.name for index in await some_table.list_indices()] == ["kept"]
@pytest.mark.asyncio
@pytest.mark.parametrize("name", ["Customer lookup", "café_idx"])
@pytest.mark.parametrize("background", [False, True])
async def test_custom_index_names_preserve_exist_ok(some_table, name, background):
method = some_table.create_index_async if background else some_table.create_index
job = await method("id", config=BTree(), name=name, exist_ok=True)
if background:
await job.wait()
version = await some_table.version()
original = await some_table.list_indices()
# A second call keeps the existing definition and version.
job = await method("id", config=Bitmap(), name=name, exist_ok=True)
if background:
await job.wait()
assert await some_table.version() == version
indices = await some_table.list_indices()
assert len(indices) == 1
assert indices[0].name == name
assert indices[0].index_type == original[0].index_type == "BTree"
assert (await some_table.index_stats(name)).num_indexed_rows == NROWS
await some_table.drop_index(name)
assert await some_table.list_indices() == []