{"record":{"id":"134ab96ce5cef0fe","repo":"microsoft/semantic-kernel","slug":"failed-to-create-astradb-settings","errorCode":null,"errorMessage":"Failed to create AstraDB settings.","messagePattern":"Failed to create AstraDB settings\\.","errorType":"exception","errorClass":"MemoryConnectorInitializationError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/memory_stores/astradb/astradb_memory_store.py","lineNumber":75,"sourceCode":"            keyspace_name (str): The Astra keyspace\n            embedding_dim (int): The dimensionality to use for new collections.\n            similarity (str): TODO\n            session: Optional session parameter\n            env_file_path (str | None): Use the environment settings file as a\n                fallback to environment variables. (Optional)\n            env_file_encoding (str | None): The encoding of the environment settings file. (Optional)\n        \"\"\"\n        try:\n            astradb_settings = AstraDBSettings(\n                app_token=astra_application_token,\n                db_id=astra_id,\n                region=astra_region,\n                keyspace=keyspace_name,\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 AstraDB settings.\", ex) from ex\n\n        self._embedding_dim = embedding_dim\n        self._similarity = similarity\n        self._session = session\n\n        if self._embedding_dim > MAX_DIMENSIONALITY:\n            raise MemoryConnectorInitializationError(\n                f\"Dimensionality of {self._embedding_dim} exceeds the maximum allowed value of {MAX_DIMENSIONALITY}.\"\n            )\n\n        self._client = AstraClient(\n            astra_id=astradb_settings.db_id,\n            astra_region=astradb_settings.region,\n            astra_application_token=(\n                astradb_settings.app_token.get_secret_value() if astradb_settings.app_token else None\n            ),\n            keyspace_name=astradb_settings.keyspace,\n            embedding_dim=embedding_dim,","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/memory_stores/astradb/astradb_memory_store.py#L57-L93","documentation":"Raised in the `AstraDBMemoryStore` constructor when constructing the pydantic `AstraDBSettings` model raises a `ValidationError`. The validation error is wrapped in a `MemoryConnectorInitializationError` (chained via `from ex`) so callers see a connector-level failure. It means one or more required settings (app token, db id, region, keyspace) are missing or invalid.","triggerScenarios":"Instantiating `AstraDBMemoryStore(...)` without supplying `astra_application_token`, `astra_id`, `astra_region`, and/or `keyspace_name`, and the corresponding environment variables (`ASTRA_DB_APP_TOKEN`, `ASTRA_DB_ID`, etc.) plus the `.env` file (via `env_file_path`) are also absent. Pydantic raises `ValidationError`; the constructor converts it to `MemoryConnectorInitializationError`.","commonSituations":"Missing `.env` file or wrong `env_file_path`; environment variables not exported in the deployment shell; `.gitignore` excluding the secrets file; CI/container missing the Astra secrets; typo in an env var name; passing an empty string where a required field is expected.","solutions":["Set the required Astra env vars: `ASTRA_DB_APP_TOKEN`, `ASTRA_DB_ID`, `ASTRA_DB_REGION`, `ASTRA_DB_KEYSPACE` (or pass them as constructor args).","Point `env_file_path` at an existing `.env` file with these values, and confirm `env_file_encoding` matches.","Inspect the chained `ValidationError` (`exc.__cause__`) for the exact missing/invalid field names.","Verify secrets are actually exported in the runtime environment (container/CI), not just in a local file."],"exampleFix":"// before\nstore = AstraDBMemoryStore(embedding_dim=1536)  # no token/id/region -> ValidationError\n\n// after\nstore = AstraDBMemoryStore(\n    astra_application_token=os.environ[\"ASTRA_DB_APP_TOKEN\"],\n    astra_id=os.environ[\"ASTRA_DB_ID\"],\n    astra_region=os.environ[\"ASTRA_DB_REGION\"],\n    keyspace_name=os.environ[\"ASTRA_DB_KEYSPACE\"],\n    embedding_dim=1536,\n)","handlingStrategy":"validation","validationCode":"import os\n\ndef astra_env_ready() -> bool:\n    required = [\"ASTRA_DB_APP_TOKEN\", \"ASTRA_DB_ID\", \"ASTRA_DB_REGION\", \"ASTRA_DB_KEYSPACE\"]\n    return all(os.getenv(v) for v in required)\n\n# assert astra_env_ready() before constructing the store","typeGuard":null,"tryCatchPattern":"from semantic_kernel.exceptions import MemoryConnectorInitializationError\ntry:\n    store = AstraDBMemoryStore(...)\nexcept MemoryConnectorInitializationError as e:\n    cause = e.__cause__  # pydantic ValidationError -> missing fields\n    raise SystemExit(f\"Astra settings invalid: {cause}\") from e","preventionTips":["Centralize Astra secrets in env vars or a `.env` and load it explicitly.","Fail fast at startup by validating required env vars exist.","Inspect `__cause__` to see exactly which pydantic fields failed.","Inject secrets into CI/containers rather than committing `.env`."],"tags":["astra-db","settings","pydantic","validation","semantic-kernel","config"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}