diff --git a/CHANGELOG.md b/CHANGELOG.md index 260a8f0c..996d04d1 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -13,6 +13,7 @@ - `doctor`'s docling-serve probe sends `X-Api-Key`, so an instance requiring a key is reported reachable rather than unreachable. - The picture-description request to the public OpenAI endpoint sends `OPENAI_API_KEY`; it carried no authorization header. +- `haiku-rag` prints the message and exits when the configured embedder does not match the database, instead of raising a traceback. ## [0.77.0] - 2026-08-21 diff --git a/haiku_rag_slim/haiku/rag/cli.py b/haiku_rag_slim/haiku/rag/cli.py index 69c1bc5a..b6d3539c 100644 --- a/haiku_rag_slim/haiku/rag/cli.py +++ b/haiku_rag_slim/haiku/rag/cli.py @@ -42,10 +42,15 @@ _cli = typer.Typer( def cli(): + # Imported here rather than at module scope: the settings module pulls in + # lancedb, and the CLI's startup must not pay for it. + from haiku.rag.store.repositories.settings import ConfigMismatchError + try: _cli() except ( AmbiguousDatabaseError, + ConfigMismatchError, MigrationRequiredError, ReadOnlyError, SourceUnavailableError, diff --git a/tests/test_cli.py b/tests/test_cli.py index 13382813..17c1df41 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -328,6 +328,22 @@ class TestResolvingTheDatabasePath: resolve_db_path(Path("/data/other.lancedb")) +class TestCliConfigMismatchError: + def test_a_config_mismatch_exits_with_its_remedy(self): + """The message says which database and what to run, so it is worth more + than a traceback.""" + from haiku.rag.store.repositories.settings import ConfigMismatchError + + with patch("haiku.rag.cli._cli") as mock_cli: + mock_cli.side_effect = ConfigMismatchError( + "database 'nemotron': vector dimension 2048 -> 2560" + ) + + with pytest.raises(SystemExit) as exc_info: + cli_wrapper() + assert exc_info.value.code == 1 + + class TestCliMigrationError: def test_catches_migration_required_error(self): with patch("haiku.rag.cli._cli") as mock_cli: