Print configuration mismatches instead of raising them

A database whose stored embedder disagrees with the configuration raised
ConfigMismatchError through Typer, so the operator got a traceback wrapped
around the one message that says what to run, while every sibling failure
exits with its message. It joins the errors the CLI reports.

Imported inside cli() rather than at module scope: the settings module
pulls in lancedb, and importing the CLI must not pay for it.
This commit is contained in:
Yiorgis Gozadinos 2026-08-21 11:45:07 +03:00
parent e15f73a387
commit 95e38e7137
No known key found for this signature in database
3 changed files with 22 additions and 0 deletions

View file

@ -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

View file

@ -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,

View file

@ -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: