{"record":{"id":"86fd6eb28f5baee9","repo":"mem0ai/mem0","slug":"when-embeddings-are-enabled-all-payloads-must-con","errorCode":null,"errorMessage":"When embeddings are enabled, all payloads must contain a 'data' field.","messagePattern":"When embeddings are enabled, all payloads must contain a 'data' field\\.","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mem0/vector_stores/upstash_vector.py","lineNumber":88,"sourceCode":"    def insert(\n        self,\n        vectors: List[list],\n        payloads: Optional[List[Dict]] = None,\n        ids: Optional[List[str]] = None,\n    ):\n        \"\"\"\n        Insert vectors\n\n        Args:\n            vectors (list): List of vectors to insert.\n            payloads (list, optional): List of payloads corresponding to vectors. These will be passed as metadatas to the Upstash Vector client. Defaults to None.\n            ids (list, optional): List of IDs corresponding to vectors. Defaults to None.\n        \"\"\"\n        logger.info(f\"Inserting {len(vectors)} vectors into namespace {self.collection_name}\")\n\n        if self.enable_embeddings:\n            if not payloads or any(\"data\" not in m or m[\"data\"] is None for m in payloads):\n                raise ValueError(\"When embeddings are enabled, all payloads must contain a 'data' field.\")\n            processed_vectors = [\n                {\n                    \"id\": ids[i] if ids else None,\n                    \"data\": payloads[i][\"data\"],\n                    \"metadata\": payloads[i],\n                }\n                for i, v in enumerate(vectors)\n            ]\n        else:\n            processed_vectors = [\n                {\n                    \"id\": ids[i] if ids else None,\n                    \"vector\": vectors[i],\n                    \"metadata\": payloads[i] if payloads else None,\n                }\n                for i, v in enumerate(vectors)\n            ]\n","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/mem0ai/mem0/blob/001c235229be8795e3834520467bd0d661ed8f34/mem0/vector_stores/upstash_vector.py#L70-L106","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"# before\nstore.insert(vectors=vecs, payloads=[{\"memory\": \"prefers tea\"}], ids=[...])\n# enable_embeddings=True -> ValueError\n\n# after\nstore.insert(vectors=vecs, payloads=[{\"data\": \"prefers tea\", \"memory\": \"prefers tea\"}], ids=[...])","handlingStrategy":"validation","validationCode":"def validate_payloads_for_embedding(payloads):\n    missing = [i for i, p in enumerate(payloads or []) if not p or p.get(\"data\") is None]\n    if payloads is None or missing:\n        raise ValueError(f\"payloads missing 'data' at indices {missing}; required when enable_embeddings=True\")\n    return payloads","typeGuard":"def payloads_have_data(payloads) -> bool:\n    return bool(payloads) and all(\n        isinstance(p, dict) and p.get(\"data\") is not None for p in payloads\n    )","tryCatchPattern":"try:\n    store.insert(vectors=vectors, payloads=payloads, ids=ids)\nexcept ValueError as e:\n    if \"'data' field\" in str(e):\n        raise ValueError(\"Embedding mode requires a non-null 'data' text in every payload\") from e\n    raise","preventionTips":["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."],"tags":["upstash","embeddings","validation","configuration","vector-store"],"backgroundTag":null,"analyzedSha":"001c235229be8795e3834520467bd0d661ed8f34","analyzedAt":"2026-08-15T01:55:42.685Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}