MemPalace/mempalace · error · ValueError

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

Error message

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

What it means

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

Source

Thrown at mempalace/backends/milvus.py:489

        else:
            entity = getattr(hit, "entity", None) or {}
            doc_id = getattr(hit, "id", None) or entity.get(FIELD_ID)
            score = getattr(hit, "distance", getattr(hit, "score", 0.0))
        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")

View on GitHub (pinned to 06cb6987f0)

Solutions

  1. Pass one document per id; pad or trim the documents list so its length equals the ids list

When it happens

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

Common situations: Caller built ids and documents lists from different sources and they drifted out of sync.


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