microsoft/semantic-kernel · error · ServiceResourceNotFoundError

Collection '{collection_name}' does not exist

Error message

Collection '{collection_name}' does not exist

What it means

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.

Source

Thrown at python/semantic_kernel/connectors/memory_stores/pinecone/pinecone_memory_store.py:182

            return True

        index_collection_names = self.pinecone.list_indexes().names()
        self.collection_names_cache |= set(index_collection_names)

        return collection_name in index_collection_names

    async def upsert(self, collection_name: str, record: MemoryRecord) -> str:
        """Upsert a record.

        Args:
            collection_name (str): The name of the collection to upsert the record into.
            record (MemoryRecord): The record to upsert.

        Returns:
            str: The unique database key of the record. In Pinecone, this is the record ID.
        """
        if not await self.does_collection_exist(collection_name):
            raise ServiceResourceNotFoundError(f"Collection '{collection_name}' does not exist")

        collection = self.pinecone.Index(collection_name)

        upsert_response = collection.upsert(
            vectors=[(record._id, record.embedding.tolist(), build_payload(record))],
            namespace="",
        )

        if upsert_response.upserted_count is None:
            raise ServiceResponseException(f"Error upserting record: {upsert_response.message}")

        return record._id

    async def upsert_batch(self, collection_name: str, records: list[MemoryRecord]) -> list[str]:
        """Upsert a batch of records.

        Args:
            collection_name (str): The name of the collection to upsert the records into.

View on GitHub (pinned to c028a0c7dc)

Solutions

  1. Call await store.create_collection(collection_name, dimension_num) before upsert.
  2. Guard with does_collection_exist and create on demand.
  3. Ensure the same Pinecone project/api_key is used across create and upsert calls.
  4. Migrate to PineconeStore + Collection.

Example fix

// before
await store.upsert("my_col", record)

// after
if not await store.does_collection_exist("my_col"):
    await store.create_collection("my_col", dimension_num=1536)
await store.upsert("my_col", record)
Defensive patterns

Strategy: validation

Validate before calling

if not await store.does_collection_exist(collection_name):
    await store.create_collection(collection_name, dimension_num=1536)
await store.upsert(collection_name, record)

Type guard

async def collection_ready(store, name: str) -> bool:
    return await store.does_collection_exist(name)

Try / catch

from semantic_kernel.exceptions import ServiceResourceNotFoundError
try:
    await store.upsert(collection_name, record)
except ServiceResourceNotFoundError:
    await store.create_collection(collection_name, dimension_num=1536)
    await store.upsert(collection_name, record)

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13). Data as JSON: /api/errors/d5137d6e5e6e1874. Report an issue: GitHub.