{"record":{"id":"d5137d6e5e6e1874","repo":"microsoft/semantic-kernel","slug":"collection-collection-name-does-not-exist-d5137d","errorCode":null,"errorMessage":"Collection '{collection_name}' does not exist","messagePattern":"Collection '(.+?)' does not exist","errorType":"exception","errorClass":"ServiceResourceNotFoundError","httpStatus":404,"severity":"error","filePath":"python/semantic_kernel/connectors/memory_stores/pinecone/pinecone_memory_store.py","lineNumber":182,"sourceCode":"            return True\n\n        index_collection_names = self.pinecone.list_indexes().names()\n        self.collection_names_cache |= set(index_collection_names)\n\n        return collection_name in index_collection_names\n\n    async def upsert(self, collection_name: str, record: MemoryRecord) -> str:\n        \"\"\"Upsert a record.\n\n        Args:\n            collection_name (str): The name of the collection to upsert the record into.\n            record (MemoryRecord): The record to upsert.\n\n        Returns:\n            str: The unique database key of the record. In Pinecone, this is the record ID.\n        \"\"\"\n        if not await self.does_collection_exist(collection_name):\n            raise ServiceResourceNotFoundError(f\"Collection '{collection_name}' does not exist\")\n\n        collection = self.pinecone.Index(collection_name)\n\n        upsert_response = collection.upsert(\n            vectors=[(record._id, record.embedding.tolist(), build_payload(record))],\n            namespace=\"\",\n        )\n\n        if upsert_response.upserted_count is None:\n            raise ServiceResponseException(f\"Error upserting record: {upsert_response.message}\")\n\n        return record._id\n\n    async def upsert_batch(self, collection_name: str, records: list[MemoryRecord]) -> list[str]:\n        \"\"\"Upsert a batch of records.\n\n        Args:\n            collection_name (str): The name of the collection to upsert the records into.","sourceCodeStart":164,"sourceCodeEnd":200,"githubUrl":"https://github.com/microsoft/semantic-kernel/blob/c028a0c7dc4f0814cdcbaba9d998f187a41197bf/python/semantic_kernel/connectors/memory_stores/pinecone/pinecone_memory_store.py#L164-L200","documentation":"Raised in PineconeMemoryStore.upsert() when does_collection_exist(collection_name) returns False. ServiceResourceNotFoundError is thrown before any Pinecone Index handle is created or vectors sent. Pinecone represents a 'collection' as an index that must be created first.","triggerScenarios":"Calling upsert() against a collection_name never created via create_collection(), created asynchronously and not yet ready, deleted, or misspelled. The in-memory collection_names_cache also drives the existence check.","commonSituations":"Forgetting to create the index before first write; index created in a different Pinecone project/account; name casing mismatch; index still provisioning after create_collection.","solutions":["Call await store.create_collection(collection_name, dimension_num) before upsert.","Guard with does_collection_exist and create on demand.","Ensure the same Pinecone project/api_key is used across create and upsert calls.","Migrate to PineconeStore + Collection."],"exampleFix":"// before\nawait store.upsert(\"my_col\", record)\n\n// after\nif not await store.does_collection_exist(\"my_col\"):\n    await store.create_collection(\"my_col\", dimension_num=1536)\nawait store.upsert(\"my_col\", record)","handlingStrategy":"validation","validationCode":"if not await store.does_collection_exist(collection_name):\n    await store.create_collection(collection_name, dimension_num=1536)\nawait store.upsert(collection_name, record)","typeGuard":"async def collection_ready(store, name: str) -> bool:\n    return await store.does_collection_exist(name)","tryCatchPattern":"from semantic_kernel.exceptions import ServiceResourceNotFoundError\ntry:\n    await store.upsert(collection_name, record)\nexcept ServiceResourceNotFoundError:\n    await store.create_collection(collection_name, dimension_num=1536)\n    await store.upsert(collection_name, record)","preventionTips":["Always create the index before the first write.","Use the same collection_name constant across create and upsert.","Confirm the Pinecone project/api_key is consistent."],"tags":["pinecone","memory-store","deprecated","collection-not-found","upsert"],"backgroundTag":null,"analyzedSha":"c028a0c7dc4f0814cdcbaba9d998f187a41197bf","analyzedAt":"2026-08-13T13:48:05.040Z","schemaVersion":2},"datasetVersion":"2026-08-13T14:17:21.547Z"}