microsoft/semantic-kernel · error · ServiceResponseException
Error upserting record: {upsert_response.message}
Error message
Error upserting record: {upsert_response.message} What it means
Raised in PineconeMemoryStore.upsert() when collection.upsert(...) returns a response whose upserted_count is None. ServiceResponseException wraps the server message from upsert_response.message. The collection exists and the call reached Pinecone, but Pinecone reported no confirmed upsert count.
Source
Thrown at python/semantic_kernel/connectors/memory_stores/pinecone/pinecone_memory_store.py:192
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.
records (List[MemoryRecord]): The records to upsert.
Returns:
List[str]: The unique database keys of the records.
"""
if not await self.does_collection_exist(collection_name):
raise ServiceResourceNotFoundError(f"Collection '{collection_name}' does not exist")
collection = self.pinecone.Index(collection_name)
View on GitHub (pinned to c028a0c7dc)
Solutions
- Inspect upsert_response.message in the exception to get the exact Pinecone reason.
- Verify record.embedding dimension equals the index's configured dimension.
- Ensure record.embedding is a non-empty ndarray and record._id is a valid Pinecone id.
- Retry on transient server messages; reduce metadata size if metadata limits are hit.
Example fix
// before
await store.upsert("my_col", record)
// after
# ensure embedding dim matches index dim, then retry on transient errors
try:
await store.upsert("my_col", record)
except ServiceResponseException as e:
log.error("pinecone upsert failed: %s", e)
raise Defensive patterns
Strategy: try-catch
Validate before calling
assert record.embedding is not None and record.embedding.shape[0] == expected_dim assert record._id and isinstance(record._id, str) await store.upsert(collection_name, record)
Type guard
def is_valid_record_for_index(record: MemoryRecord, dim: int) -> bool:
return record.embedding is not None and record.embedding.shape[0] == dim Try / catch
from semantic_kernel.exceptions import ServiceResponseException
try:
await store.upsert(collection_name, record)
except ServiceResponseException as e:
# e message carries upsert_response.message from Pinecone
logger.error("upsert rejected by Pinecone: %s", e)
raise Prevention
- Match record.embedding dimension to the index dimension.
- Inspect the server message in the exception for the real cause.
- Retry transient server errors with backoff.
When it happens
Trigger: Pinecone returned a non-success response with a populated message (e.g., vector dimension mismatch with the index, malformed vector, rate limit, or a transient server error). The empty-count heuristic treats any None count as failure.
Common situations: Embedding dimension in the record differs from the index dimension; embedding field is None/empty; payload exceeds Pinecone metadata size limits; transient Pinecone-side error.
Related errors
- Collection '{collection_name}' does not exist
- Upsert failed
- Dimensionality of {default_dimensionality} exceeds the maxim
- Failed to create Pinecone settings.
- Dimensionality of {dimension_num} exceeds the maximum allowe
AI-assisted analysis of microsoft/semantic-kernel@c028a0c7dc (2026-08-13).
Data as JSON: /api/errors/4ff2272a68bd2db2.
Report an issue: GitHub.