{"record":{"id":"de95926ccf9b6254","repo":"MemPalace/mempalace","slug":"milvus-consistency-level-must-be-one-of-allowed","errorCode":null,"errorMessage":"milvus_consistency_level must be one of: {allowed}","messagePattern":"milvus_consistency_level must be one of: (.+?)","errorType":"exception","errorClass":"BackendError","httpStatus":null,"severity":"error","filePath":"mempalace/backends/milvus.py","lineNumber":306,"sourceCode":"        db_name = (\n            options.get(\"db_name\")\n            or os.environ.get(\"MEMPALACE_MILVUS_DB_NAME\")\n            or getattr(cfg, \"milvus_db_name\", None)\n        )\n        namespace = (\n            options.get(\"namespace\")\n            or os.environ.get(\"MEMPALACE_MILVUS_NAMESPACE\")\n            or getattr(cfg, \"milvus_namespace\", None)\n        )\n        try:\n            consistency_level = (\n                options.get(\"consistency_level\")\n                or os.environ.get(\"MEMPALACE_MILVUS_CONSISTENCY_LEVEL\")\n                or getattr(cfg, \"milvus_consistency_level\", DEFAULT_MILVUS_CONSISTENCY_LEVEL)\n            )\n            consistency_level = normalize_milvus_consistency_level(consistency_level)\n        except ValueError as exc:\n            raise BackendError(str(exc)) from exc\n        db_filename = options.get(\"db_filename\") or DEFAULT_DB_FILENAME\n        return cls(\n            uri=str(uri).strip() if uri else None,\n            token=str(token) if token else None,\n            db_name=str(db_name).strip() if db_name else None,\n            namespace=str(namespace).strip() if namespace else None,\n            db_filename=str(db_filename).strip() or DEFAULT_DB_FILENAME,\n            consistency_level=consistency_level,\n        )\n\n\nclass MilvusCollection(BaseCollection):\n    def __init__(\n        self,\n        *,\n        backend: \"MilvusBackend\",\n        client: Any,\n        config: _MilvusConfig,","sourceCodeStart":288,"sourceCodeEnd":324,"githubUrl":"https://github.com/MemPalace/mempalace/blob/06cb6987f02610784fefbad4b2bd5d026d164ba6/mempalace/backends/milvus.py#L288-L324","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Set the env var to a valid level: MEMPALACE_MILVUS_CONSISTENCY_LEVEL=Strong (or Session/Bounded/Eventually; case-insensitive)","Fix the value in config (milvus_consistency_level) or the options dict passed to create_backend()","Unset the variable to fall back to the default Strong"],"exampleFix":"# before\nexport MEMPALACE_MILVUS_CONSISTENCY_LEVEL=QUORUM\nbackend = MilvusBackend.create_backend(options={})\n\n# after\nexport MEMPALACE_MILVUS_CONSISTENCY_LEVEL=Bounded\nbackend = MilvusBackend.create_backend(options={})","handlingStrategy":"validation","validationCode":"ALLOWED = {\"strong\", \"session\", \"bounded\", \"eventually\"}\n\ndef valid_consistency_level(value: str) -> bool:\n    return str(value).strip().lower() in ALLOWED\n\n# before create_backend:\nassert valid_consistency_level(os.environ.get(\"MEMPALACE_MILVUS_CONSISTENCY_LEVEL\", \"Strong\"))","typeGuard":null,"tryCatchPattern":"from mempalace.backends.base import BackendError\ntry:\n    backend = MilvusBackend.create_backend(options={})\nexcept BackendError as e:\n    if \"consistency_level\" in str(e):\n        os.environ[\"MEMPALACE_MILVUS_CONSISTENCY_LEVEL\"] = \"Strong\"\n        backend = MilvusBackend.create_backend(options={})\n    else:\n        raise","preventionTips":["Use only Strong/Session/Bounded/Eventually (case-insensitive)","Validate env vars in a startup config check before backend creation","Do not copy consistency names from other databases"],"tags":["milvus","configuration","consistency-level","env-vars"],"backgroundTag":null,"analyzedSha":"06cb6987f02610784fefbad4b2bd5d026d164ba6","analyzedAt":"2026-08-15T03:03:36.213Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}