MemPalace/mempalace · error · ValueError

query input must be a non-empty list

Error message

query input must be a non-empty list

What it means

A SearchError raised when the underlying chromadb collection.query() call throws: the raw exception is printed and re-wrapped so callers only ever need to handle SearchError, with the original chained via `from e`. The root cause is whatever chromadb raised — bad where-filter, dimension mismatch, corrupted index, connection issues.

Source

Thrown at mempalace/backends/chroma.py:1747

    def query(
        self,
        *,
        query_texts=None,
        query_embeddings=None,
        n_results=10,
        where=None,
        where_document=None,
        include=None,
    ) -> QueryResult:
        _validate_where(where)
        _validate_where(where_document)

        if (query_texts is None) == (query_embeddings is None):
            raise ValueError("query requires exactly one of query_texts or query_embeddings")
        chosen = query_texts if query_texts is not None else query_embeddings
        if not chosen:
            raise ValueError("query input must be a non-empty list")

        spec = _IncludeSpec.resolve(include, default_distances=True)
        chroma_include: list[str] = []
        if spec.documents:
            chroma_include.append("documents")
        if spec.metadatas:
            chroma_include.append("metadatas")
        if spec.distances:
            chroma_include.append("distances")
        if spec.embeddings:
            chroma_include.append("embeddings")

        kwargs: dict[str, Any] = {
            "n_results": n_results,
            "include": chroma_include,
        }
        if query_texts is not None:
            kwargs["query_texts"] = query_texts

View on GitHub (pinned to 06cb6987f0)

Solutions

  1. Read the inner {e} text — it names the actual chromadb failure.
  2. If it mentions dimension/embedding mismatch, re-mine or repair the palace with the current embedding setup.
  3. If it mentions the metric/space, run the palace repair to set hnsw:space=cosine.
  4. Re-run with a simpler query (no wing/room filter) to isolate whether the where-filter is the trigger.

Example fix

try:
    results = search_memories('query', palace_path=palace)
except SearchError as e:
    log.warning('search failed: %s', e)
    results = []  # degrade gracefully at the call site
Defensive patterns

Strategy: try-catch

Try / catch

try:
    results = search_memories(query, palace_path=palace_path)
except SearchError:
    results = []  # memory is an augmentation; degrade, don't crash the host app

Prevention

When it happens

Trigger: col.query(query_texts=[...], n_results=..., include=[...]) raising inside the try block — e.g. embedding-model dimension drift between palace creation and search, malformed where filter, or a corrupted HNSW index.

Common situations: Querying a palace built with a different embedding function/model; legacy palaces missing hnsw:space=cosine; chromadb internal errors after partial corruption.

Related errors


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