MemPalace/mempalace · error · ValueError

metadatas length {len(metadatas)} does not match ids length

Error message

metadatas length {len(metadatas)} does not match ids length {len(ids)}

What it means

Error "metadatas length {len(metadatas)} does not match ids length {len(ids)}" thrown in MemPalace/mempalace.

Source

Thrown at mempalace/backends/milvus.py:493

        row = dict(entity or {})
        row[FIELD_ID] = str(doc_id)
        row["distance"] = float(score or 0.0)
        return row

    def _prepare_rows(
        self,
        *,
        documents: list[str],
        ids: list[str],
        metadatas: Optional[list[dict]],
        embeddings: list[list[float]],
    ) -> tuple[list[dict], int]:
        if len(documents) != len(ids):
            raise ValueError(
                f"documents length {len(documents)} does not match ids length {len(ids)}"
            )
        if metadatas is not None and len(metadatas) != len(ids):
            raise ValueError(
                f"metadatas length {len(metadatas)} does not match ids length {len(ids)}"
            )
        if len(embeddings) != len(ids):
            raise ValueError(
                f"embeddings length {len(embeddings)} does not match ids length {len(ids)}"
            )
        vectors, dimension = _normalize_vectors(embeddings)
        metadatas = metadatas or [{} for _ in ids]
        rows = []
        for idx, (doc_id, document, metadata, vector) in enumerate(
            zip(ids, documents, metadatas, vectors)
        ):
            if not isinstance(doc_id, str) or not doc_id:
                raise ValueError(f"row {idx}: id must be a non-empty string")
            doc_id_bytes = _utf8_len(doc_id)
            if doc_id_bytes > DRAWER_ID_MAX_LENGTH:
                raise ValueError(
                    f"row {idx}: id byte length {doc_id_bytes} exceeds {DRAWER_ID_MAX_LENGTH}"

View on GitHub (pinned to 06cb6987f0)

Solutions

  1. Pass one metadata dict per id; align the metadatas list with the ids list

When it happens

Trigger: Thrown at mempalace/backends/milvus.py:493 when the library encounters an invalid state.

Common situations: Metadatas list was constructed separately from ids and lengths diverged.


AI-assisted analysis of MemPalace/mempalace@06cb6987f0 (2026-08-15). Data as JSON: /api/errors/a71505d182f9787b. Report an issue: GitHub.