{"record":{"id":"a2ac9b3a1eae4099","repo":"MemPalace/mempalace","slug":"operator-key-r-not-supported-by-chroma-backend","errorCode":null,"errorMessage":"operator {key!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":384,"sourceCode":"    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\")\n        actual = meta.get(key)\n        if isinstance(expected, dict):\n            for op, operand in expected.items():\n                if not _compare_metadata(actual, op, operand):\n                    return False\n        elif actual != expected:\n            return False\n    return True\n\n\ndef _metadata_cell_value(sval, ival, fval, bval):\n    if sval is not None:\n        return sval\n    if ival is not None:\n        return ival\n    if fval is not None:\n        return fval\n    if bval is not None:","sourceCodeStart":366,"sourceCodeEnd":402,"githubUrl":"https://github.com/MemPalace/mempalace/blob/06cb6987f02610784fefbad4b2bd5d026d164ba6/mempalace/backends/chroma.py#L366-L402","documentation":"A ValueError from replica identity loading: the replica file parsed, but replica_id is not a string matching the expected id pattern. Same rationale as the corrupt-file case — minting a second id for one palace would fork op-log provenance, so the invalid file must be restored or deleted explicitly.","triggerScenarios":"load_or_mint_replica_id() reads data['replica_id'] that is a non-string (int, null, list) or a string failing the _REPLICA_ID_RE format check.","commonSituations":"Hand-editing replica.json and storing the wrong type; a migration script writing an unquoted id; template placeholders like \"REPLICA_ID\" left in the file.","solutions":["Restore the correct original replica_id string from a palace backup.","If the original id is lost and you accept forking provenance, delete the file and let it re-mint a valid id.","If scripting writes to this file, validate the value against the id pattern before writing."],"exampleFix":null,"handlingStrategy":"type-guard","validationCode":"import json, re\nfrom pathlib import Path\ndata = json.loads((Path(palace_path)/'replica.json').read_text())\nrid = data.get('replica_id')\nassert isinstance(rid, str) and re.match(r'^rep_[0-9a-f]+$', rid), f'bad replica_id: {rid!r}'","typeGuard":"def has_valid_replica_id(palace_path: str) -> bool:\n    try:\n        data = json.loads((Path(palace_path)/'replica.json').read_text(encoding='utf-8'))\n    except Exception:\n        return False\n    return isinstance(data.get('replica_id'), str)","tryCatchPattern":"try:\n    rid = load_or_mint_replica_id(palace_path)\nexcept ValueError as e:\n    if 'invalid replica_id' in str(e):\n        restore_original_id_from_backup()  # or intentionally delete to re-mint","preventionTips":["Copy replica_id values verbatim (string, original format) when scripting palace copies.","Validate the id pattern before writing the file in any tooling."],"tags":["replication","identity","validation","json"],"backgroundTag":null,"analyzedSha":"06cb6987f02610784fefbad4b2bd5d026d164ba6","analyzedAt":"2026-08-15T03:03:36.213Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}