From a0ca693101a80a20e52fb8e19ec0773c249f5eea Mon Sep 17 00:00:00 2001 From: Yiorgis Gozadinos Date: Sat, 25 Apr 2026 09:21:20 +0300 Subject: [PATCH] Resolve db_path before handing it to lancedb.connect_async. Closes #355 --- CHANGELOG.md | 4 ++++ haiku_rag_slim/haiku/rag/store/engine.py | 2 +- tests/test_lancedb_connection.py | 15 ++++++++++++++- 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 356a7d7a..91669595 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,10 @@ # Changelog ## [Unreleased] +### Fixed + +- **`Store` and CLI commands accept relative database paths again.** The 0.43 migration to `lancedb.connect_async` started routing the path through LanceDB's async URI sanitizer, which treats anything that doesn't look like an absolute local path as a possibly-cloud URI and demands `api_key`/`region`, surfacing as `ValueError: An api_key is required when connecting to LanceDb Cloud`. The path is now resolved to absolute before being handed to LanceDB. + ## [0.43.0] - 2026-04-24 ### Changed diff --git a/haiku_rag_slim/haiku/rag/store/engine.py b/haiku_rag_slim/haiku/rag/store/engine.py index 55a328f7..28e6d07f 100644 --- a/haiku_rag_slim/haiku/rag/store/engine.py +++ b/haiku_rag_slim/haiku/rag/store/engine.py @@ -70,7 +70,7 @@ async def connect_lancedb( else: if db_path is None: raise ValueError("No lancedb.uri configured and no db_path provided") - return await lancedb.connect_async(db_path) + return await lancedb.connect_async(db_path.resolve()) class DocumentRecord(LanceModel): diff --git a/tests/test_lancedb_connection.py b/tests/test_lancedb_connection.py index 39301411..83c63ae3 100644 --- a/tests/test_lancedb_connection.py +++ b/tests/test_lancedb_connection.py @@ -49,7 +49,20 @@ class TestConnectLancedb: "haiku.rag.store.engine.lancedb.connect_async", new_callable=AsyncMock ) as mock_connect: await connect_lancedb(config, db_path=temp_db_path) - mock_connect.assert_called_once_with(temp_db_path) + mock_connect.assert_called_once_with(temp_db_path.resolve()) + + @pytest.mark.asyncio + async def test_local_resolves_relative_db_path(self, tmp_path, monkeypatch): + from pathlib import Path + + monkeypatch.chdir(tmp_path) + relative = Path("db/rag/rag.lancedb") + config = AppConfig(lancedb=LanceDBConfig(uri="")) + with patch( + "haiku.rag.store.engine.lancedb.connect_async", new_callable=AsyncMock + ) as mock_connect: + await connect_lancedb(config, db_path=relative) + mock_connect.assert_called_once_with((tmp_path / relative).resolve()) @pytest.mark.asyncio async def test_cloud_passes_uri_api_key_region(self):