{"record":{"id":"6da499dd8d3d6ac2","repo":"MemPalace/mempalace","slug":"operator-op-r-not-supported-by-chroma-backend","errorCode":null,"errorMessage":"operator {op!r} not supported by chroma backend","messagePattern":"operator (.+?) not supported by chroma backend","errorType":"exception","errorClass":"UnsupportedFilterError","httpStatus":null,"severity":"error","filePath":"mempalace/backends/chroma.py","lineNumber":366,"sourceCode":"        return actual != expected\n    if op == \"$in\":\n        return actual in (expected or [])\n    if op == \"$nin\":\n        return actual not in (expected or [])\n    if op == \"$contains\":\n        return str(expected) in str(actual or \"\")\n    try:\n        if op == \"$gt\":\n            return actual > expected\n        if op == \"$gte\":\n            return actual >= expected\n        if op == \"$lt\":\n            return actual < expected\n        if op == \"$lte\":\n            return actual <= expected\n    except TypeError:\n        return False\n    raise UnsupportedFilterError(f\"operator {op!r} not supported by chroma backend\")\n\n\ndef _matches_where(meta: dict, where: Optional[dict]) -> bool:\n    if not where:\n        return True\n    if not isinstance(where, dict):\n        return False\n    for key, expected in where.items():\n        if key == \"$and\":\n            if not all(_matches_where(meta, clause) for clause in expected or []):\n                return False\n            continue\n        if key == \"$or\":\n            if not any(_matches_where(meta, clause) for clause in expected or []):\n                return False\n            continue\n        if key.startswith(\"$\"):\n            raise UnsupportedFilterError(f\"operator {key!r} not supported by chroma backend\")","sourceCodeStart":348,"sourceCodeEnd":384,"githubUrl":"https://github.com/MemPalace/mempalace/blob/06cb6987f02610784fefbad4b2bd5d026d164ba6/mempalace/backends/chroma.py#L348-L384","documentation":"A ValueError from replica identity loading: the palace's replica file exists but cannot be parsed as JSON or lacks the replica_id key. The code refuses to mint a second identity because two replica ids for one palace would fork its op-log provenance — the caller must restore or delete the corrupt file explicitly.","triggerScenarios":"load_or_mint_replica_id() finds the replica file but json.loads or the data['replica_id'] access raises (ValueError/KeyError/TypeError) — truncated write, hand-edited file, or wrong file dropped in place.","commonSituations":"A crash or disk-full event truncated the JSON; a sync tool merged the file badly; the user created the file manually with wrong structure.","solutions":["Inspect the file at the printed path — if it is truncated/garbled, restore it from a backup of the palace.","If you intentionally want a NEW identity (accepting that this replica's provenance history is abandoned), delete the file explicitly and let the tool re-mint.","Never hand-edit a replacement JSON in place unless it is valid {\"replica_id\": \"...\"} with the original id."],"exampleFix":"path = Path(palace_path) / 'replica.json'\ntry:\n    rid = load_or_mint_replica_id(palace_path)\nexcept ValueError:\n    # decide deliberately: restore old identity from backup, or\n    # os.remove(path) to intentionally mint a fresh one","handlingStrategy":"try-catch","validationCode":"import json\nfrom pathlib import Path\np = Path(palace_path) / 'replica.json'\nif p.exists():\n    json.loads(p.read_text(encoding='utf-8'))['replica_id']  # fail early, clearly","typeGuard":"def is_valid_replica_file(palace_path: str) -> bool:\n    p = Path(palace_path) / 'replica.json'\n    if not p.is_file():\n        return True  # absent is fine; will be minted\n    try:\n        return isinstance(json.loads(p.read_text())['replica_id'], str)\n    except (ValueError, KeyError, TypeError):\n        return False","tryCatchPattern":"try:\n    rid = load_or_mint_replica_id(palace_path)\nexcept ValueError as e:\n    if backup_available():\n        restore_replica_json_from_backup()\n    else:\n        raise SystemExit(f'replica identity unreadable: {e}; delete {path} to re-mint')","preventionTips":["Include replica.json in palace backups.","Never hand-edit the replica file; treat it as opaque.","Ensure disk space during operations that write it (atomic tmp+rename guards truncation but not external corruption)."],"tags":["replication","identity","corrupt-file","json"],"backgroundTag":null,"analyzedSha":"06cb6987f02610784fefbad4b2bd5d026d164ba6","analyzedAt":"2026-08-15T03:03:36.213Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}