{"record":{"id":"c6bc07d115991f3d","repo":"microsoft/semantic-kernel","slug":"failed-to-create-pinecone-settings","errorCode":null,"errorMessage":"Failed to create Pinecone settings.","messagePattern":"Failed to create Pinecone settings\\.","errorType":"exception","errorClass":"MemoryConnectorInitializationError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/memory_stores/pinecone/pinecone_memory_store.py","lineNumber":77,"sourceCode":"        Args:\n            api_key (str): The Pinecone API key.\n            default_dimensionality (int): The default dimensionality to use for new collections.\n            env_file_path (str | None): Use the environment settings file as a fallback\n                to environment variables. (Optional)\n            env_file_encoding (str | None): The encoding of the environment settings file. (Optional)\n        \"\"\"\n        if default_dimensionality > MAX_DIMENSIONALITY:\n            raise MemoryConnectorInitializationError(\n                f\"Dimensionality of {default_dimensionality} exceeds the maximum allowed value of {MAX_DIMENSIONALITY}.\"\n            )\n        try:\n            pinecone_settings = PineconeSettings(\n                api_key=api_key,\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 Pinecone settings.\", ex) from ex\n\n        self._default_dimensionality = default_dimensionality\n\n        self.pinecone = Pinecone(api_key=pinecone_settings.api_key.get_secret_value())\n        self.collection_names_cache = set()\n\n    async def create_collection(\n        self,\n        collection_name: str,\n        dimension_num: int | None = None,\n        distance_type: str | None = \"cosine\",\n        index_spec: NamedTuple = DEFAULT_INDEX_SPEC,\n    ) -> None:\n        \"\"\"Creates a new collection in Pinecone if it does not exist.\n\n        This function creates an index, by default the following index\n        settings are used: metric = cosine, cloud = aws, region = us-east-1.\n","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/memory_stores/pinecone/pinecone_memory_store.py#L59-L95","documentation":"Raised in PineconeMemoryStore.__init__ when constructing PineconeSettings raises a pydantic ValidationError. The settings object resolves the API key from the constructor arg or .env fallback; if validation fails (most often a missing/empty API key), the error is wrapped as MemoryConnectorInitializationError with the original ValidationError chained via 'from ex'. The Pinecone client is never created.","triggerScenarios":"Constructing PineconeMemoryStore without an api_key and with no PINECONE_API_KEY environment variable or .env file; providing an empty/None api_key; a malformed .env at the given env_file_path.","commonSituations":"Deploying without the PINECONE_API_KEY secret set; .env file not loaded in the deployed environment; api_key pulled from a secret manager that returned None; env_file_encoding mismatch corrupting the parsed value.","solutions":["Set the PINECONE_API_KEY environment variable, or pass api_key explicitly to the constructor.","Inspect the chained ValidationError (ex) in the traceback to see exactly which field failed.","Verify env_file_path points to a readable .env containing a valid PINECONE_API_KEY.","Migrate to PineconeStore + Collection and supply settings there."],"exampleFix":"// before\nstore = PineconeMemoryStore(api_key=None, default_dimensionality=1536)\n\n// after\nimport os\nkey = os.environ[\"PINECONE_API_KEY\"]  # fail loudly if missing\nstore = PineconeMemoryStore(api_key=key, default_dimensionality=1536)","handlingStrategy":"try-catch","validationCode":"import os\napi_key = api_key or os.environ.get(\"PINECONE_API_KEY\")\nif not api_key:\n    raise RuntimeError(\"PINECONE_API_KEY is required\")\nstore = PineconeMemoryStore(api_key=api_key, default_dimensionality=1536)","typeGuard":"def has_pinecone_credentials() -> bool:\n    return bool(os.environ.get(\"PINECONE_API_KEY\"))","tryCatchPattern":"from semantic_kernel.exceptions.memory_connector_exceptions import MemoryConnectorInitializationError\ntry:\n    store = PineconeMemoryStore(api_key=key, default_dimensionality=1536)\nexcept MemoryConnectorInitializationError as e:\n    # e.__cause__ is the pydantic ValidationError with the failing field\n    raise SystemExit(f\"Pinecone settings invalid: {e.__cause__}\") from e","preventionTips":["Set PINECONE_API_KEY in every environment (env or secret manager).","Fail fast on missing secrets at startup, not at first API call.","Inspect the chained ValidationError to see the exact field."],"tags":["pinecone","memory-store","deprecated","configuration","api-key","init","secrets"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}