From d9db83de65a94bcac2563d180f51754571b1ed1e Mon Sep 17 00:00:00 2001
From: "lancedb-gatefixer[bot]"
<313497061+lancedb-gatefixer[bot]@users.noreply.github.com>
Date: Mon, 30 Nov 2026 20:51:19 +0800
Subject: [PATCH] fix!: guard remote index routes against dot segments (#5013)
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
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.
## 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).
Snapshot:
[6b25e10](https://github.com/lancedb/lancedb/commit/6b25e10810ea1d11a4ef56be63c4ef50225f65d6)
---------
Co-authored-by: Gatefixer <313497061+lancedb-gatefixer[bot]@users.noreply.github.com>
---
docs/src/js/classes/Table.md | 8 +-
docs/src/js/interfaces/IndexOptions.md | 4 +
docs/web/indexing/vector-index.mdx | 12 +
nodejs/lancedb/indices.ts | 4 +
nodejs/lancedb/table.ts | 8 +-
python/python/lancedb/table.py | 18 ++
python/python/tests/test_index.py | 24 ++
rust/lancedb/src/remote/table.rs | 356 +++++++++++++++++++++----
rust/lancedb/src/table.rs | 14 +-
rust/lancedb/src/table/create_index.rs | 83 ++++++
10 files changed, 472 insertions(+), 59 deletions(-)
diff --git a/docs/src/js/classes/Table.md b/docs/src/js/classes/Table.md
index 01258aa4a..282b9d659 100644
--- a/docs/src/js/classes/Table.md
+++ b/docs/src/js/classes/Table.md
@@ -425,8 +425,9 @@ Indices on vector columns will speed up vector searches.
Indices on scalar columns will speed up filtering (in both
vector and non-vector searches)
-We currently don't support custom named indexes.
-The index name will always be `${column}_idx`.
+The index name defaults to `${column}_idx`. Set [IndexOptions.name](../interfaces/IndexOptions.md#name)
+to use a custom name.
+See [IndexOptions.name](../interfaces/IndexOptions.md#name) for legacy-name cleanup guidance.
On LanceDB Embedded tables the index is built before the returned promise
resolves. On LanceDB Enterprise tables it resolves once the build is
@@ -1185,6 +1186,9 @@ abstract listIndices(): Promise
List all indices that have been created with [Table.createIndex](Table.md#createindex)
+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 `numUnindexedRows` may be undefined. Use
diff --git a/docs/src/js/interfaces/IndexOptions.md b/docs/src/js/interfaces/IndexOptions.md
index e0990fc8d..f119a178a 100644
--- a/docs/src/js/interfaces/IndexOptions.md
+++ b/docs/src/js/interfaces/IndexOptions.md
@@ -35,6 +35,10 @@ optional name: string;
Optional custom name for the index.
If not provided, a default name will be generated based on the column name.
+Existing and generated names remain addressable through index operations,
+except that remote tables reject empty names, `.` and `..` to prevent URL
+path normalization. Existing `.` or `..` indices on managed tables require
+server-side cleanup, or a native connection with direct dataset access.
***
diff --git a/docs/web/indexing/vector-index.mdx b/docs/web/indexing/vector-index.mdx
index 2800463af..5023b1e27 100644
--- a/docs/web/indexing/vector-index.mdx
+++ b/docs/web/indexing/vector-index.mdx
@@ -341,6 +341,18 @@ These fields are populated for LanceDB Embedded tables. In LanceDB Enterprise, `
The `{column}_idx` suffix is the default naming convention.
Pass `name=...` to `create_index()` to override it. Once set, the custom name will be reflected in `list_indices()`, `index_stats(name)`, and `wait_for_index([name])`.
+{/*
+Draft for the Enterprise index-route safety fix (#5007). Publish this guidance
+after the SDK changes ship.
+
+Remote tables reject empty names, `.` and `..` in index operations to prevent
+URL path normalization. Existing indexes named `.` or `..` require
+server-side cleanup on managed tables, or a native connection with direct
+access to the dataset. Other existing names remain usable. On older Enterprise
+servers, index listings omit these unaddressable entries so they do not prevent
+listing or waiting for other indices.
+*/}
+
{VectorIndexCustomName}
diff --git a/nodejs/lancedb/indices.ts b/nodejs/lancedb/indices.ts
index 4d91ffc8f..b4bdf1a9e 100644
--- a/nodejs/lancedb/indices.ts
+++ b/nodejs/lancedb/indices.ts
@@ -1112,6 +1112,10 @@ export interface IndexOptions {
* Optional custom name for the index.
*
* If not provided, a default name will be generated based on the column name.
+ * Existing and generated names remain addressable through index operations,
+ * except that remote tables reject empty names, `.` and `..` to prevent URL
+ * path normalization. Existing `.` or `..` indices on managed tables require
+ * server-side cleanup, or a native connection with direct dataset access.
*/
name?: string;
diff --git a/nodejs/lancedb/table.ts b/nodejs/lancedb/table.ts
index 1dad81719..5dc1c445e 100644
--- a/nodejs/lancedb/table.ts
+++ b/nodejs/lancedb/table.ts
@@ -597,8 +597,9 @@ export abstract class Table {
* Indices on scalar columns will speed up filtering (in both
* vector and non-vector searches)
*
- * We currently don't support custom named indexes.
- * The index name will always be `${column}_idx`.
+ * The index name defaults to `${column}_idx`. Set {@link IndexOptions.name}
+ * to use a custom name.
+ * See {@link IndexOptions.name} for legacy-name cleanup guidance.
*
* On LanceDB Embedded tables the index is built before the returned promise
* resolves. On LanceDB Enterprise tables it resolves once the build is
@@ -1666,6 +1667,9 @@ export abstract class Table {
/**
* List all indices that have been created with {@link Table.createIndex}
*
+ * 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 `numUnindexedRows` may be undefined. Use
diff --git a/python/python/lancedb/table.py b/python/python/lancedb/table.py
index b930b77d6..3d950ce7b 100644
--- a/python/python/lancedb/table.py
+++ b/python/python/lancedb/table.py
@@ -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
diff --git a/python/python/tests/test_index.py b/python/python/tests/test_index.py
index c38948eb2..c3bd5c62a 100644
--- a/python/python/tests/test_index.py
+++ b/python/python/tests/test_index.py
@@ -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() == []
diff --git a/rust/lancedb/src/remote/table.rs b/rust/lancedb/src/remote/table.rs
index 2d576887e..6198dcfdc 100644
--- a/rust/lancedb/src/remote/table.rs
+++ b/rust/lancedb/src/remote/table.rs
@@ -87,6 +87,7 @@ use lance_core::datatypes::Schema as LanceSchema;
use lance_datafusion::exec::{OneShotExec, execute_plan};
use reqwest::{RequestBuilder, Response};
use serde::{Deserialize, Serialize};
+use std::borrow::Cow;
use std::collections::{HashMap, HashSet};
use std::io::Cursor;
use std::pin::Pin;
@@ -102,6 +103,18 @@ const MIN_READ_VERSION_HEADER: HeaderName = HeaderName::from_static("x-lancedb-m
const VERSION_HEADER: HeaderName = HeaderName::from_static("x-lancedb-version");
const QUERY_SNAPSHOT_HEADER: &str = "x-lancedb-query-snapshot";
+/// Encode an index name as one safe path segment.
+fn encode_index_name(name: &str) -> Result> {
+ // Percent-encoding preserves dot segments, which URL parsing would normalize
+ // into another route. All other name characters are safe after encoding.
+ if matches!(name, "" | "." | "..") {
+ return Err(Error::InvalidInput {
+ message: format!("Illegal index name '{name}' in remote route."),
+ });
+ }
+ Ok(urlencoding::encode(name))
+}
+
fn valid_query_snapshot_identity(value: &str) -> bool {
value.strip_prefix("v1:").is_some_and(|digest| {
digest.len() == 64
@@ -2704,7 +2717,8 @@ impl RemoteTable {
index_name: &str,
read_snapshot: ReadSnapshot,
) -> Result