mem0ai/mem0 · error · ValueError
When embeddings are enabled, all payloads must contain a 'da
Error message
When embeddings are enabled, all payloads must contain a 'data' field.
What it means
Raised in UpstashVector.insert when enable_embeddings=True but any payload lacks a 'data' key (or has data=None). In embedding mode the store sends the payload's 'data' text to Upstash to embed server-side instead of using the client-supplied vectors, so every record must carry the source text. The check is all-or-nothing: one malformed payload fails the whole batch.
Source
Thrown at mem0/vector_stores/upstash_vector.py:88
def insert(
self,
vectors: List[list],
payloads: Optional[List[Dict]] = None,
ids: Optional[List[str]] = None,
):
"""
Insert vectors
Args:
vectors (list): List of vectors to insert.
payloads (list, optional): List of payloads corresponding to vectors. These will be passed as metadatas to the Upstash Vector client. Defaults to None.
ids (list, optional): List of IDs corresponding to vectors. Defaults to None.
"""
logger.info(f"Inserting {len(vectors)} vectors into namespace {self.collection_name}")
if self.enable_embeddings:
if not payloads or any("data" not in m or m["data"] is None for m in payloads):
raise ValueError("When embeddings are enabled, all payloads must contain a 'data' field.")
processed_vectors = [
{
"id": ids[i] if ids else None,
"data": payloads[i]["data"],
"metadata": payloads[i],
}
for i, v in enumerate(vectors)
]
else:
processed_vectors = [
{
"id": ids[i] if ids else None,
"vector": vectors[i],
"metadata": payloads[i] if payloads else None,
}
for i, v in enumerate(vectors)
]
View on GitHub (pinned to 001c235229)
Solutions
- Ensure every metadata dict passed to add/insert includes a non-null 'data' field with the text to embed.
- If your payloads use another key, remap before insert: `{**p, "data": p["text"]}`.
- If you actually want client-side embeddings (mem0 computes vectors), remove enable_embeddings so the vectors argument is used instead.
Example fix
# before
store.insert(vectors=vecs, payloads=[{"memory": "prefers tea"}], ids=[...])
# enable_embeddings=True -> ValueError
# after
store.insert(vectors=vecs, payloads=[{"data": "prefers tea", "memory": "prefers tea"}], ids=[...]) Defensive patterns
Strategy: validation
Validate before calling
def validate_payloads_for_embedding(payloads):
missing = [i for i, p in enumerate(payloads or []) if not p or p.get("data") is None]
if payloads is None or missing:
raise ValueError(f"payloads missing 'data' at indices {missing}; required when enable_embeddings=True")
return payloads Type guard
def payloads_have_data(payloads) -> bool:
return bool(payloads) and all(
isinstance(p, dict) and p.get("data") is not None for p in payloads
) Try / catch
try:
store.insert(vectors=vectors, payloads=payloads, ids=ids)
except ValueError as e:
if "'data' field" in str(e):
raise ValueError("Embedding mode requires a non-null 'data' text in every payload") from e
raise Prevention
- Standardize on a 'data' key for the embeddable text when enable_embeddings is on.
- Validate the whole batch before insert — one bad payload fails all of it.
- If you embed client-side, keep enable_embeddings off and pass vectors.
When it happens
Trigger: Config with `"enable_embeddings": true` (or the constructor flag) plus an `add()`/`insert()` where metadata payloads contain keys like 'memory' or 'text' but not 'data'; payloads=None; records where 'data' was set to None by upstream cleanup.
Common situations: Flipping enable_embeddings on an existing integration whose payloads predate the 'data' convention; custom embedder pipelines writing 'content' instead of 'data'; one record in a batch differing in schema from the rest.
Related errors
- Baidu vector store requires a non-empty '${name}' config val
- Baidu Mochow table '${label}' stores ${dimension}-dimensiona
- ${label} dimension mismatch. Expected ${this.dimension}, got
- Extra fields not allowed: {', '.join(extra_fields)}. Please
- Invalid compression_type: {values['compression_type']}. Must
AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15).
Data as JSON: /api/errors/86fd6eb28f5baee9.
Report an issue: GitHub.