{"record":{"id":"693372f5e8d6c87a","repo":"zylon-ai/private-gpt","slug":"migration-client-is-not-available-for-store-stor","errorCode":null,"errorMessage":"Migration client is not available for store '{store}'","messagePattern":"Migration client is not available for store '(.+?)'","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"private_gpt/components/persistence/persistence_component.py","lineNumber":91,"sourceCode":"                raise ValueError(f\"Unsupported store type: {store}\")\n\n    def apply_migrations(self) -> None:\n        with self._lock:\n            if self._migrations_applied:\n                logger.info(\"Migrations already applied in this process; skipping\")\n                return\n\n            store = self._settings.database.provider\n            schema = self._settings.database.schema_name\n            logger.info(\n                \"Applying migrations with provider=%s schema=%s total=%s\",\n                store,\n                schema,\n                len(MIGRATIONS),\n            )\n            client = self.get_client(store)\n            if client is None:\n                raise ValueError(\n                    f\"Migration client is not available for store '{store}'\"\n                )\n\n            migration_backend: MigrationBackend = self._get_migration_backend(\n                store=store,\n                client=client,\n            )\n            runner = MigrationRunner(migration_backend)\n            runner.run_up(migrations=list(MIGRATIONS))\n            self._migrations_applied = True\n            logger.info(\"Migrations applied successfully\")\n\n    # Testing use: This method will revert all migrations\n    def revert_migrations(self) -> None:\n        with self._lock:\n            store = self._settings.database.provider\n            schema = self._settings.database.schema_name\n            logger.info(","sourceCodeStart":73,"sourceCodeEnd":109,"githubUrl":"https://github.com/zylon-ai/private-gpt/blob/4a030776a31a901ad80b1bf4d7faa2c1a367efbb/private_gpt/components/persistence/persistence_component.py#L73-L109","documentation":"`apply_migrations` (guarded by a lock and an idempotency flag) resolves the client via `self.get_client(store)`; a None return raises `ValueError` saying no migration client is available for the configured provider. In practice `get_client` returns None only when the `match store` in `get_client` falls through without assigning — i.e. a provider value handled by neither the postgres nor sqlite branch.","triggerScenarios":"Startup with `database.provider` set to an unrecognized value: `get_client`'s match falls through, caches nothing, returns None, and `apply_migrations` raises; also possible if a custom store branch returns None explicitly.","commonSituations":"Provider typos (e.g. 'none', 'postgres '); config drift between what `get_client` supports and what callers assume; environment-specific overrides with stale provider names.","solutions":["Set `database.provider` to a value supported by `get_client` ('postgres' or 'sqlite')","Fix typos/casing in the provider setting","If extending with a new store, implement both the client branch and the migration backend branch so `get_client` never returns None"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"client = persistence.get_client(settings.database.provider)\nif client is None:\n    raise ValueError(\n        f\"no client for provider {settings.database.provider!r}; expected postgres or sqlite\"\n    )","typeGuard":null,"tryCatchPattern":"try:\n    persistence.apply_migrations()\nexcept ValueError as e:\n    if \"Migration client is not available\" in str(e):\n        raise SystemExit(f\"fix database.provider: {e}\") from e\n    raise","preventionTips":["Run migrations in a startup probe that fails loudly with the provider value logged","Keep a single source of truth for supported providers shared by get_client and the migration backend"],"tags":["migrations","persistence","configuration","startup"],"backgroundTag":null,"analyzedSha":"4a030776a31a901ad80b1bf4d7faa2c1a367efbb","analyzedAt":"2026-08-15T03:51:26.951Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}