zylon-ai/private-gpt · error · ValueError

local_path is required for sqlite client

Error message

local_path is required for sqlite client

What it means

In `PersistenceComponent.get_client`, the 'sqlite' branch reads `settings.database.local_path` and raises `ValueError` when it is None before constructing the lazy SQLite factory. SQLite persistence requires an on-disk database file location; the settings schema allows it to be unset, and this is the startup-time enforcement.

Source

Thrown at private_gpt/components/persistence/persistence_component.py:46

        if store in self._clients:
            return self._clients[store]

        client: Any | None = None
        match store:
            case "postgres":
                from private_gpt.components.postgres.postgres_client import (
                    LazyPostgresFactory,
                )

                client = LazyPostgresFactory.get_instance(self._settings)
            case "sqlite":
                from private_gpt.components.sqlite.sqlite_client import (
                    LazySQLiteFactory,
                )

                local_path = self._settings.database.local_path
                if local_path is None:
                    raise ValueError("local_path is required for sqlite client")
                client = LazySQLiteFactory.get_instance(self._settings)

        self._clients[store] = client
        return client

    def _get_migration_backend(
        self,
        store: str,
        client: Any,
    ) -> MigrationBackend:
        match store:
            case "postgres" | "sqlite":
                from private_gpt.components.migrations.backend.sqlalchemy_backend import (
                    SQLAlchemyMigrationBackend,
                )

                engine = client.sync_session.kw.get("bind")
                if engine is None:

View on GitHub (pinned to 4a030776a3)

Solutions

  1. Set `database.local_path` in settings (e.g. `/data/app.db` or `./local.db`) to a writable location
  2. Ensure the path's parent directory exists and the process has write permission
  3. In containers, back the path with a volume if persistence across restarts is needed

Example fix

# before
database:
  provider: sqlite
  # local_path missing -> ValueError

# after
database:
  provider: sqlite
  local_path: /var/lib/privategpt/app.db
Defensive patterns

Strategy: validation

Validate before calling

if settings.database.provider == "sqlite" and not settings.database.local_path:
    raise ValueError("database.local_path must be set when provider is sqlite")

Prevention

When it happens

Trigger: Setting `database.provider: sqlite` (or defaulting to it) without setting `database.local_path`; env-specific settings files that omit the path; running the persistence/migration component init which calls `get_client('sqlite')`.

Common situations: Fresh local setup copying a template settings file that lacks `local_path`; switching from postgres to sqlite provider without adding the path; container deployments forgetting to mount/configure the db path.

Related errors


AI-assisted analysis of zylon-ai/private-gpt@4a030776a3 (2026-08-15). Data as JSON: /api/errors/7e2149b4ab162df2. Report an issue: GitHub.