MemPalace/mempalace · error · ValueError

candidate_strategy must be one of {tuple(_CANDIDATE_MERGERS)

Error message

candidate_strategy must be one of {tuple(_CANDIDATE_MERGERS)}, got {strategy!r}

What it means

Error "candidate_strategy must be one of {tuple(_CANDIDATE_MERGERS)}, got {strategy!r}" thrown in MemPalace/mempalace.

Source

Thrown at mempalace/searcher.py:1218

# Strategy dispatch — keeps search_memories' branch count under the
# project's complexity ceiling (C901 max-complexity=25). New strategies
# register here.
_CANDIDATE_MERGERS = {
    "vector": None,  # default no-op
    "union": _merge_bm25_union_candidates,
}


def _validate_candidate_strategy(strategy: str) -> None:
    """Raise ``ValueError`` for unknown strategies.

    Called eagerly at the top of ``search_memories`` so invalid values
    fail consistently regardless of whether the call routes through the
    vector path, the BM25-only fallback, or returns an early error dict.
    """
    if strategy not in _CANDIDATE_MERGERS:
        raise ValueError(
            f"candidate_strategy must be one of {tuple(_CANDIDATE_MERGERS)}, got {strategy!r}"
        )


def _apply_candidate_strategy(
    strategy: str,
    hits: list,
    drawers_col,
    query: str,
    wing: str,
    room: str,
    n_results: int,
    max_distance: float = 0.0,
    source_file: str = None,
    since_dt=None,
    before_dt=None,
) -> None:
    """Dispatch to the registered merger for ``strategy``.

View on GitHub (pinned to 06cb6987f0)

Solutions

  1. Pass one of the listed candidate_strategy values

When it happens

Trigger: Thrown at mempalace/searcher.py:1218 when the library encounters an invalid state.

Common situations: An unknown candidate merge strategy name was configured.


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