MemPalace/mempalace · error · ValueError

{label} length {len(value)} does not match ids length {n}

Error message

{label} length {len(value)} does not match ids length {n}

What it means

A plain FileNotFoundError from _read_sidecar_seq_ids: repair_max_seq_id(from_sidecar=...) was given a sidecar SQLite database path that does not exist as a file. The sidecar is the source of truth for restoring segment seq_ids, so the operation cannot proceed without it.

Source

Thrown at mempalace/backends/base.py:569

        metadatas: Optional[list[dict]] = None,
        embeddings: Optional[list[list[float]]] = None,
    ) -> None:
        """Default non-atomic update: get + merge + upsert.

        Backends advertising ``supports_update`` MUST override with an atomic
        single-round-trip implementation.
        """
        if documents is None and metadatas is None and embeddings is None:
            raise ValueError("update requires at least one of documents, metadatas, embeddings")

        n = len(ids)
        for label, value in (
            ("documents", documents),
            ("metadatas", metadatas),
            ("embeddings", embeddings),
        ):
            if value is not None and len(value) != n:
                raise ValueError(f"{label} length {len(value)} does not match ids length {n}")

        existing = self.get(ids=ids, include=["documents", "metadatas"])
        by_id = {
            rid: (existing.documents[i], existing.metadatas[i])
            for i, rid in enumerate(existing.ids)
        }
        merged_docs: list[str] = []
        merged_metas: list[dict] = []
        for i, rid in enumerate(ids):
            prev_doc, prev_meta = by_id.get(rid, ("", {}))
            merged_docs.append(documents[i] if documents is not None else prev_doc)
            new_meta = dict(prev_meta or {})
            if metadatas is not None:
                new_meta.update(metadatas[i] or {})
            merged_metas.append(new_meta)
        self.upsert(
            documents=merged_docs,
            ids=list(ids),

View on GitHub (pinned to 06cb6987f0)

Solutions

  1. Check the path exists: sidecars live inside the palace's segment directories — locate with a find for the exact filename.
  2. Use an absolute path to the sidecar file.
  3. Verify you are pointing at the sidecar belonging to the affected segment, not another palace copy.

Example fix

from pathlib import Path
sidecar = Path(sidecar).expanduser().resolve()
if not sidecar.is_file():
    raise SystemExit(f'no sidecar at {sidecar}')
repair_max_seq_id(palace_path, from_sidecar=str(sidecar))
Defensive patterns

Strategy: validation

Validate before calling

from pathlib import Path
p = Path(sidecar_path).expanduser().resolve()
if not p.is_file():
    sidecars = list(Path(palace_path).rglob('*max_seq_id*'))
    raise SystemExit(f'not a file: {p}; candidates: {sidecars}')

Prevention

When it happens

Trigger: Calling repair_max_seq_id() with from_sidecar pointing at a nonexistent or misspelled path (typo, wrong segment directory, relative path resolved from the wrong cwd).

Common situations: Passing a relative sidecar path while running from a different working directory; pointing at a sidecar from the wrong chromadb segment folder; the file was deleted during earlier cleanup.

Related errors


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