MemPalace/mempalace · error · BackendError

milvus_consistency_level must be one of: {allowed}

Error message

milvus_consistency_level must be one of: {allowed}

What it means

Raised in MilvusBackend.create_backend() when the configured consistency level is not one of Strong, Session, Bounded, Eventually. The value is resolved from options, then MEMPALACE_MILVUS_CONSISTENCY_LEVEL, then config, normalized by normalize_milvus_consistency_level(), and a bad value raises ValueError which is wrapped into BackendError with this exact message from config.py:245.

Source

Thrown at mempalace/backends/milvus.py:306

        db_name = (
            options.get("db_name")
            or os.environ.get("MEMPALACE_MILVUS_DB_NAME")
            or getattr(cfg, "milvus_db_name", None)
        )
        namespace = (
            options.get("namespace")
            or os.environ.get("MEMPALACE_MILVUS_NAMESPACE")
            or getattr(cfg, "milvus_namespace", None)
        )
        try:
            consistency_level = (
                options.get("consistency_level")
                or os.environ.get("MEMPALACE_MILVUS_CONSISTENCY_LEVEL")
                or getattr(cfg, "milvus_consistency_level", DEFAULT_MILVUS_CONSISTENCY_LEVEL)
            )
            consistency_level = normalize_milvus_consistency_level(consistency_level)
        except ValueError as exc:
            raise BackendError(str(exc)) from exc
        db_filename = options.get("db_filename") or DEFAULT_DB_FILENAME
        return cls(
            uri=str(uri).strip() if uri else None,
            token=str(token) if token else None,
            db_name=str(db_name).strip() if db_name else None,
            namespace=str(namespace).strip() if namespace else None,
            db_filename=str(db_filename).strip() or DEFAULT_DB_FILENAME,
            consistency_level=consistency_level,
        )


class MilvusCollection(BaseCollection):
    def __init__(
        self,
        *,
        backend: "MilvusBackend",
        client: Any,
        config: _MilvusConfig,

View on GitHub (pinned to 06cb6987f0)

Solutions

  1. Set the env var to a valid level: MEMPALACE_MILVUS_CONSISTENCY_LEVEL=Strong (or Session/Bounded/Eventually; case-insensitive)
  2. Fix the value in config (milvus_consistency_level) or the options dict passed to create_backend()
  3. Unset the variable to fall back to the default Strong

Example fix

# before
export MEMPALACE_MILVUS_CONSISTENCY_LEVEL=QUORUM
backend = MilvusBackend.create_backend(options={})

# after
export MEMPALACE_MILVUS_CONSISTENCY_LEVEL=Bounded
backend = MilvusBackend.create_backend(options={})
Defensive patterns

Strategy: validation

Validate before calling

ALLOWED = {"strong", "session", "bounded", "eventually"}

def valid_consistency_level(value: str) -> bool:
    return str(value).strip().lower() in ALLOWED

# before create_backend:
assert valid_consistency_level(os.environ.get("MEMPALACE_MILVUS_CONSISTENCY_LEVEL", "Strong"))

Try / catch

from mempalace.backends.base import BackendError
try:
    backend = MilvusBackend.create_backend(options={})
except BackendError as e:
    if "consistency_level" in str(e):
        os.environ["MEMPALACE_MILVUS_CONSISTENCY_LEVEL"] = "Strong"
        backend = MilvusBackend.create_backend(options={})
    else:
        raise

Prevention

When it happens

Trigger: MEMPALACE_MILVUS_CONSISTENCY_LEVEL=Bounded-stale (typo) in the environment; options={"consistency_level": "QUORUM"} (a Z/constants renamed or unsupported level); config file milvus_consistency_level: weekly.

Common situations: Copy-pasting consistency names from other databases (Cassandra QUORUM/LOCAL_ONE, Mongo readConcern); version drift if allowed levels change; case is actually tolerant (lowercase accepted) but misspellings are not.

Related errors


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