From 042df3d8261f4b6fbcfb668162583ba9b1d2aed3 Mon Sep 17 00:00:00 2001 From: Gordon Murray Date: Wed, 10 Jun 2026 20:07:58 +0100 Subject: [PATCH] fix: use list_tables() when available, table_names() is deprecated Newer lancedb deprecates table_names() in favor of list_tables(), which returns a ListTablesResponse with the names in .tables. The viewer supports versions back to 0.3.1 that only have table_names(), so /datasets picks whichever the connection provides. Fixes #54 --- CHANGELOG.md | 1 + backend/app.py | 7 ++++++- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index d70f74e..8930ae9 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -14,6 +14,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Fixed - Frontend fetch calls now check `response.ok` before parsing JSON, so HTTP error responses surface as error states instead of being parsed as data (#27). - `/rows` with unknown column names and `/vector/preview` with a missing or non-vector column now return 400 as intended; the error was previously masked as a generic 500 (#28). +- `/datasets` uses `list_tables()` on lancedb versions that have it, falling back to the deprecated `table_names()` on older ones (#54). ### Docs - README refresh: corrected the supported-data-types section (variable-length float vectors render fully since #14; no 2048-dimension limit), documented the release image tags from #46, added test suite instructions, made 0.29.2 the recommendation throughout, and linked CONTRIBUTING.md and CHANGELOG.md (#51). diff --git a/backend/app.py b/backend/app.py index e399d54..288c50f 100644 --- a/backend/app.py +++ b/backend/app.py @@ -174,7 +174,12 @@ async def health_check(): async def list_datasets(): try: db = get_lance_connection() - table_names = db.table_names() + if hasattr(db, "list_tables"): + table_names = db.list_tables().tables + else: + # table_names() was deprecated in favor of list_tables(), + # but older lancedb versions only have table_names() + table_names = db.table_names() valid_tables = [name for name in table_names if validate_dataset_name(name)] return {"datasets": valid_tables} except Exception as e: