{"record":{"id":"f1630692df0798ce","repo":"microsoft/semantic-kernel","slug":"failed-to-create-postgres-settings","errorCode":null,"errorMessage":"Failed to create Postgres settings.","messagePattern":"Failed to create Postgres settings\\.","errorType":"exception","errorClass":"MemoryConnectorInitializationError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/memory_stores/postgres/postgres_memory_store.py","lineNumber":71,"sourceCode":"\n        Args:\n            connection_string: The connection string to the Postgres database.\n            default_dimensionality: The default dimensionality of the embeddings.\n            min_pool: The minimum number of connections in the connection pool.\n            max_pool: The maximum number of connections in the connection pool.\n            schema: The schema to use. (default: {\"public\"})\n            env_file_path: Use the environment settings file as a fallback\n                to environment variables. (Optional)\n            env_file_encoding: The encoding of the environment settings file.\n        \"\"\"\n        try:\n            postgres_settings = PostgresSettings(\n                connection_string=connection_string,\n                env_file_path=env_file_path,\n                env_file_encoding=env_file_encoding,\n            )\n        except ValidationError as ex:\n            raise MemoryConnectorInitializationError(\"Failed to create Postgres settings.\", ex) from ex\n\n        min_pool = min_pool or postgres_settings.min_pool\n        max_pool = max_pool or postgres_settings.max_pool\n\n        self._check_dimensionality(default_dimensionality)\n\n        self._default_dimensionality = default_dimensionality\n        self._connection_pool = ConnectionPool(\n            min_size=min_pool, max_size=max_pool, open=True, kwargs=postgres_settings.get_connection_args()\n        )\n        self._schema = schema\n        atexit.register(self._connection_pool.close)\n\n    async def create_collection(\n        self,\n        collection_name: str,\n        dimension_num: int | None = None,\n    ) -> None:","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/memory_stores/postgres/postgres_memory_store.py#L53-L89","documentation":"Raised in PostgresMemoryStore.__init__ when constructing PostgresSettings raises a pydantic ValidationError. The error is wrapped as MemoryConnectorInitializationError('Failed to create Postgres settings.') with the original ValidationError chained. PostgresSettings resolves the connection_string from the arg or .env fallback; failure most often means a missing/invalid connection string or pool size bounds violation.","triggerScenarios":"Constructing PostgresMemoryStore without a connection_string and with no POSTGRES_CONNECTION_STRING env var/.env; providing a malformed connection string; min_pool/max_pool env values out of allowed range.","commonSituations":"Deployment missing the POSTGRES_CONNECTION_STRING secret; .env not loaded in prod; connection string lacks required pgvector/SSL params; pool size env vars misconfigured.","solutions":["Set POSTGRES_CONNECTION_STRING (or pass connection_string) with a valid postgres:// URI including host, user, password, dbname.","Inspect the chained ValidationError to see the exact failing field.","Verify env_file_path points to a readable .env with the connection string.","Migrate to PostgresStore + Collection."],"exampleFix":"// before\nstore = PostgresMemoryStore(connection_string=None, default_dimensionality=1536)\n\n// after\nimport os\nconn = os.environ[\"POSTGRES_CONNECTION_STRING\"]\nstore = PostgresMemoryStore(connection_string=conn, default_dimensionality=1536)","handlingStrategy":"try-catch","validationCode":"import os\nconn = connection_string or os.environ.get(\"POSTGRES_CONNECTION_STRING\")\nif not conn:\n    raise RuntimeError(\"POSTGRES_CONNECTION_STRING is required\")\nstore = PostgresMemoryStore(connection_string=conn, default_dimensionality=1536)","typeGuard":"def has_postgres_credentials() -> bool:\n    return bool(os.environ.get(\"POSTGRES_CONNECTION_STRING\"))","tryCatchPattern":"from semantic_kernel.exceptions.memory_connector_exceptions import MemoryConnectorInitializationError\ntry:\n    store = PostgresMemoryStore(connection_string=conn, default_dimensionality=1536)\nexcept MemoryConnectorInitializationError as e:\n    raise SystemExit(f\"Postgres settings invalid: {e.__cause__}\") from e","preventionTips":["Set POSTGRES_CONNECTION_STRING in every environment.","Inspect the chained ValidationError for the exact failing field.","Validate the URI includes host/user/password/dbname and any required SSL params."],"tags":["postgres","memory-store","deprecated","configuration","connection-string","init","secrets"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}