{"record":{"id":"9f8e0d760045181e","repo":"microsoft/semantic-kernel","slug":"dimensionality-of-dimension-num-exceeds-the-maxi-9f8e0d","errorCode":null,"errorMessage":"Dimensionality of {dimension_num} exceeds the maximum allowed value of {MAX_DIMENSIONALITY}.","messagePattern":"Dimensionality of (.+?) exceeds the maximum allowed value of (.+?)\\.","errorType":"exception","errorClass":"ServiceInitializationError","httpStatus":null,"severity":"error","filePath":"python/semantic_kernel/connectors/memory_stores/pinecone/pinecone_memory_store.py","lineNumber":108,"sourceCode":"    ) -> 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\n        Args:\n            collection_name (str): The name of the collection to create.\n                In Pinecone, a collection is represented as an index. The concept\n                of \"collection\" in Pinecone is just a static copy of an index.\n            dimension_num (int, optional): The dimensionality of the embeddings.\n            distance_type (str, optional): The distance metric to use for the index.\n                (default: {\"cosine\"})\n            index_spec (NamedTuple, optional): The index spec to use for the index.\n        \"\"\"\n        if dimension_num is None:\n            dimension_num = self._default_dimensionality\n        if dimension_num > MAX_DIMENSIONALITY:\n            raise ServiceInitializationError(\n                f\"Dimensionality of {dimension_num} exceeds \" + f\"the maximum allowed value of {MAX_DIMENSIONALITY}.\"\n            )\n\n        if not await self.does_collection_exist(collection_name):\n            self.pinecone.create_index(\n                name=collection_name, dimension=dimension_num, metric=distance_type, spec=index_spec\n            )\n            self.collection_names_cache.add(collection_name)\n\n    async def describe_collection(self, collection_name: str) -> IndexModel | None:\n        \"\"\"Gets the description of the index.\n\n        Args:\n            collection_name (str): The name of the index to get.\n\n        Returns:\n            Optional[dict]: The index.\n        \"\"\"","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/memory_stores/pinecone/pinecone_memory_store.py#L90-L126","documentation":"Raised in PineconeMemoryStore.create_collection() when the resolved dimensionality (explicit dimension_num or the store's _default_dimensionality) exceeds MAX_DIMENSIONALITY (20000). Unlike the constructor check this throws ServiceInitializationError. It fires before any does_collection_exist / create_index call.","triggerScenarios":"Calling create_collection(collection_name, dimension_num=N) with N > 20000, or omitting dimension_num so the store falls back to a _default_dimensionality that is > 20000 (which itself would have failed at construction).","commonSituations":"Per-collection override with a huge dimension; embedding model changed to one exceeding the Pinecone limit; dimension read from config without clamping.","solutions":["Pass a dimension_num <= 20000 from a supported embedding model.","Do not override dimension_num and rely on a valid _default_dimensionality set at construction.","Clamp/validate the dimension at the call site against MAX_DIMENSIONALITY.","Migrate to PineconeStore + Collection."],"exampleFix":"// before\nawait store.create_collection(\"big\", dimension_num=50000)\n\n// after\nawait store.create_collection(\"big\", dimension_num=1536)","handlingStrategy":"validation","validationCode":"from semantic_kernel.connectors.memory_stores.pinecone.pinecone_memory_store import MAX_DIMENSIONALITY\ndim = dimension_num if dimension_num is not None else store._default_dimensionality\nif dim > MAX_DIMENSIONALITY:\n    raise ValueError(f\"dimension {dim} exceeds Pinecone max {MAX_DIMENSIONALITY}\")\nawait store.create_collection(collection_name, dimension_num=dimension_num)","typeGuard":"def is_valid_collection_dim(d: int | None, default_d: int) -> bool:\n    return (d if d is not None else default_d) <= 20000","tryCatchPattern":"from semantic_kernel.exceptions import ServiceInitializationError\ntry:\n    await store.create_collection(name, dimension_num=dim)\nexcept ServiceInitializationError as e:\n    raise ValueError(f\"cannot create collection {name}: {e}\") from e","preventionTips":["Pass an explicit, validated dimension_num rather than relying on the default.","Confirm the embedding model dimension before create_collection.","Clamp dimension from config."],"tags":["pinecone","memory-store","deprecated","dimensionality","create-collection"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}