{"record":{"id":"933d0254bd80e884","repo":"MemPalace/mempalace","slug":"milvus-consistency-level-must-be-one-of-allowed-933d02","errorCode":null,"errorMessage":"milvus_consistency_level must be one of: {allowed}","messagePattern":"milvus_consistency_level must be one of: (.+?)","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mempalace/config.py","lineNumber":245,"sourceCode":"    \"session\": \"Session\",\n    \"bounded\": \"Bounded\",\n    \"eventually\": \"Eventually\",\n}\n\n# How many timestamped palace backups to retain before the oldest are\n# pruned. Applies to the accumulating backups written by ``mempalace\n# migrate`` and ``mempalace repair max-seq-id`` — see\n# ``MempalaceConfig.max_backups``.\nDEFAULT_MAX_BACKUPS = 10\n\n\ndef normalize_milvus_consistency_level(value) -> str:\n    raw = str(value).strip() if value else DEFAULT_MILVUS_CONSISTENCY_LEVEL\n    normalized = _MILVUS_CONSISTENCY_LEVELS.get(raw.lower())\n    if normalized:\n        return normalized\n    allowed = \", \".join(_MILVUS_CONSISTENCY_LEVELS.values())\n    raise ValueError(f\"milvus_consistency_level must be one of: {allowed}\")\n\n\ndef sqlite_read_uri(db_path: str) -> str:\n    \"\"\"Return a read-only ``file:`` URI for ``sqlite3.connect(..., uri=True)``.\n\n    A bare ``f\"file:{db_path}?mode=ro\"`` mis-parses paths containing spaces or\n    other URI-reserved characters — common in real home directories (a Windows\n    user folder like ``First Last``, many macOS paths). ``pathname2url``\n    percent-encodes the path and normalizes separators so the database opens on\n    every platform.\n    \"\"\"\n    from urllib.request import pathname2url\n\n    db_path = os.fspath(db_path)\n    return f\"file:{pathname2url(db_path)}?mode=ro\"\n\n\n@lru_cache(maxsize=1)","sourceCodeStart":227,"sourceCodeEnd":263,"githubUrl":"https://github.com/MemPalace/mempalace/blob/06cb6987f02610784fefbad4b2bd5d026d164ba6/mempalace/config.py#L227-L263","documentation":"Thrown by normalize_milvus_consistency_level() in mempalace/config.py when the configured Milvus consistency level does not match any of the known levels (typically Strong, Bounded, Session, Eventually, and their prefix aliases). The value is stripped and lowercased, then looked up in the _MILVUS_CONSISTENCY_LEVELS alias map; a miss raises ValueError listing the allowed canonical names. This guards the Milvus backend's read-consistency setting before it ever reaches the Milvus client.","triggerScenarios":"Passing milvus_consistency_level=\"strict\" (typo for 'strong'), \"Eventually \" with unusual casing is fine but a completely unknown word like \"fast\" is not; setting it via config file, MEMPALACE_* env var, or a MilvusBackend constructor argument with an unsupported level; passing an empty string (falsy) actually falls back to the default, so only non-empty unknown strings trigger it.","commonSituations":"Copy-pasting a consistency level from Milvus 2.x docs that this version's alias map doesn't include; upgrading Milvus which renames levels while MemPalace's map lags; typos in YAML/JSON config (unquoted values, trailing characters); CI config differing from local config.","solutions":["Read the allowed list in the error message and use one of those exact canonical values (e.g. 'Strong', 'Bounded', 'Session', 'Eventually').","Check for typos, stray whitespace/quotes, or YAML type coercion in the milvus_consistency_level key of your config file.","Omit the setting entirely to accept the default (DEFAULT_MILVUS_CONSISTENCY_LEVEL) if you don't need a specific level.","If you need a level the map doesn't know (e.g. a new Milvus release), open an issue/PR to add the alias to _MILVUS_CONSISTENCY_LEVELS in mempalace/config.py."],"exampleFix":"# before\nconfig = {\"milvus_consistency_level\": \"strict\"}\n\n# after\nconfig = {\"milvus_consistency_level\": \"Strong\"}","handlingStrategy":"validation","validationCode":"from mempalace.config import _MILVUS_CONSISTENCY_LEVELS, normalize_milvus_consistency_level\n\ndef valid_level(value: str) -> bool:\n    try:\n        normalize_milvus_consistency_level(value)\n        return True\n    except ValueError:\n        return False\n\nassert valid_level(cfg.get(\"milvus_consistency_level\", \"Strong\"))","typeGuard":"def is_milvus_level(value: object) -> bool:\n    return isinstance(value, str) and value.strip().lower() in {\n        \"strong\", \"bounded\", \"session\", \"eventually\"\n    }","tryCatchPattern":"try:\n    level = normalize_milvus_consistency_level(raw)\nexcept ValueError as exc:\n    raise ConfigError(f\"fix milvus_consistency_level: {exc}\") from exc","preventionTips":["Validate config values once at load time and fail with field context instead of deep in backend calls.","Quote consistency levels in YAML/JSON to avoid type coercion.","Pin config examples to the canonical names listed in the error message."],"tags":["config","validation","milvus","backend"],"backgroundTag":null,"analyzedSha":"06cb6987f02610784fefbad4b2bd5d026d164ba6","analyzedAt":"2026-08-15T03:03:36.213Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}