{"record":{"id":"2d359f671e89632d","repo":"MemPalace/mempalace","slug":"label-count-mismatch-expected-expected-got","errorCode":null,"errorMessage":"{label} count mismatch: expected {expected}, got {actual}","messagePattern":"(.+?) count mismatch: expected (.+?), got (.+?)","errorType":"exception","errorClass":"RuntimeError","httpStatus":null,"severity":"error","filePath":"mempalace/repair.py","lineNumber":312,"sourceCode":"        # chromadb 1.5.x's upsert validates that every metadatas[i] is a\n        # non-empty dict (chromadb/api/types.py:validate_metadata). Drawers\n        # extracted from sqlite ground truth can come back with None or {}\n        # for sparse historical writes — coerce those to a sentinel so the\n        # rebuild upsert can complete instead of raising ValueError ~80%\n        # through a multi-hour run. See #1458 for full context.\n        sanitized_metas = [\n            m if (isinstance(m, dict) and len(m) > 0) else {\"_repaired_empty_meta\": True}\n            for m in batch[\"metadatas\"]\n        ]\n        all_metas.extend(sanitized_metas)\n        offset += len(batch[\"ids\"])\n    return all_ids, all_docs, all_metas\n\n\ndef _verify_collection_count(col, expected: int, label: str) -> None:\n    actual = col.count()\n    if actual != expected:\n        raise RuntimeError(f\"{label} count mismatch: expected {expected}, got {actual}\")\n\n\ndef _is_missing_collection_value_error(exc: ValueError) -> bool:\n    message = str(exc).lower()\n    return \"does not exist\" in message or \"not found\" in message\n\n\ndef _delete_collection_if_exists(backend, palace_path: str, collection_name: str) -> None:\n    try:\n        backend.delete_collection(palace_path, collection_name)\n    except ValueError as exc:\n        if _is_missing_collection_value_error(exc):\n            return\n        raise\n    except (FileNotFoundError, ChromaNotFoundError):\n        return\n\n","sourceCodeStart":294,"sourceCodeEnd":330,"githubUrl":"https://github.com/MemPalace/mempalace/blob/06cb6987f02610784fefbad4b2bd5d026d164ba6/mempalace/repair.py#L294-L330","documentation":"Error \"{label} count mismatch: expected {expected}, got {actual}\" thrown in MemPalace/mempalace.","triggerScenarios":"Thrown at mempalace/repair.py:312 when the library encounters an invalid state.","commonSituations":"Post-rebuild verification counted a different number of rows than expected.","solutions":["Re-run the repair or investigate why the rebuilt count differs from the source count"],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"06cb6987f02610784fefbad4b2bd5d026d164ba6","analyzedAt":"2026-08-15T03:03:36.213Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}