mem0ai/mem0 · error · ValueError

Vector at index {idx} is null. This usually means the embedd

Error message

Vector at index {idx} is null. This usually means the embedding model failed to generate an embedding. Check that your embedding model is configured correctly and returning valid vectors.

What it means

insert() in the OpenSearch store rejects a None entry in the vectors list before writing anything. A None vector means the embedding model returned nothing for that text (API failure silently swallowed, wrong key, empty input), and indexing it would corrupt the store's vector field.

Source

Thrown at mem0/vector_stores/opensearch.py:164

                except Exception:
                    retry_count += 1
                    if retry_count == max_retries:
                        raise TimeoutError(f"Index {name} creation timed out after {max_retries} seconds")
                    time.sleep(0.5)

    def insert(
        self, vectors: List[List[float]], payloads: Optional[List[Dict]] = None, ids: Optional[List[str]] = None
    ) -> List[OutputData]:
        """Insert vectors into the index."""
        if not ids:
            ids = [str(i) for i in range(len(vectors))]

        if payloads is None:
            payloads = [{} for _ in range(len(vectors))]

        for idx, vec in enumerate(vectors):
            if vec is None:
                raise ValueError(
                    f"Vector at index {idx} is null. "
                    f"This usually means the embedding model failed to generate an embedding. "
                    f"Check that your embedding model is configured correctly and returning valid vectors."
                )
            if len(vec) == 0:
                raise ValueError(
                    f"Vector at index {idx} is empty. "
                    f"Expected a vector of dimension {self.embedding_model_dims}, got an empty vector."
                )
            if len(vec) != self.embedding_model_dims:
                raise ValueError(
                    f"Vector at index {idx} has dimension {len(vec)}, "
                    f"but the index '{self.collection_name}' expects dimension {self.embedding_model_dims}. "
                    f"Ensure your embedding model's output dimensions match the vector store configuration."
                )

        results = []
        for i, (vec, id_) in enumerate(zip(vectors, ids)):

View on GitHub (pinned to 001c235229)

Solutions

  1. Fix the embedding step so it either returns a real vector or raises — never None
  2. Check embedding provider credentials/quota if vectors come back None intermittently
  3. Pre-validate: assert all(v is not None for v in vectors) with the index of the offender logged before insert

Example fix

# before
store.insert(vectors=[v1, None, v3], payloads=ps, ids=ids)

# after
bad = [i for i, v in enumerate(vectors) if v is None]
if bad:
    raise ValueError(f"embeddings missing at {bad}; check the embedder")
store.insert(vectors=vectors, payloads=ps, ids=ids)
Defensive patterns

Strategy: validation

Validate before calling

missing = [i for i, v in enumerate(vectors) if v is None]
if missing:
    raise ValueError(f"embedding model returned None at positions {missing}")
store.insert(vectors=vectors, payloads=payloads, ids=ids)

Type guard

def all_embeddings_present(vectors) -> bool:
    return all(v is not None for v in vectors)

Try / catch

try:
    store.insert(vectors, payloads, ids)
except ValueError as e:
    if "is null" in str(e):
        idx = int(str(e).split("index ")[1].split(" is")[0])
        vectors[idx] = embedder.embed(texts[idx])  # re-embed the failure
        store.insert(vectors, payloads, ids)
    else:
        raise

Prevention

When it happens

Trigger: Calling add()/insert where the embedder returned None for one of the texts: embedding API errors swallowed by a wrapper, mismatched batch counts, or a stub embedder in tests returning None.

Common situations: Embedding provider outage or rate-limit where the client returns None instead of raising; custom embedding classes not implementing embed() for all inputs; blank documents passed through the memory pipeline.

Related errors


AI-assisted analysis of mem0ai/mem0@001c235229 (2026-08-15). Data as JSON: /api/errors/1c18e2a83821bdd4. Report an issue: GitHub.