{"record":{"id":"82da3a3da5681963","repo":"MemPalace/mempalace","slug":"path-holds-an-invalid-replica-id-replica-id-r","errorCode":null,"errorMessage":"{path} holds an invalid replica_id {replica_id!r}; refusing to mint a second identity — restore or delete the file explicitly","messagePattern":"(.+?) holds an invalid replica_id (.+?); refusing to mint a second identity — restore or delete the file explicitly","errorType":"exception","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"mempalace/replica.py","lineNumber":50,"sourceCode":"    \"\"\"Return this palace's stable replica id, minting it on first use.\n\n    The file is written atomically (tmp + rename) so a crash mid-mint can\n    never leave a half-written identity; a corrupt or foreign-shaped file\n    fails loudly rather than silently minting a second identity — two ids\n    for one replica would fork its op-log provenance.\n    \"\"\"\n    path = Path(os.path.expanduser(palace_path)) / REPLICA_FILENAME\n    if path.exists():\n        try:\n            data = json.loads(path.read_text(encoding=\"utf-8\"))\n            replica_id = data[\"replica_id\"]\n        except (ValueError, KeyError, TypeError) as exc:\n            raise ValueError(\n                f\"{path} is corrupt ({exc}); refusing to mint a second replica \"\n                \"identity for this palace — restore or delete the file explicitly\"\n            ) from None\n        if not isinstance(replica_id, str) or not _REPLICA_ID_RE.match(replica_id):\n            raise ValueError(\n                f\"{path} holds an invalid replica_id {replica_id!r}; refusing to \"\n                \"mint a second identity — restore or delete the file explicitly\"\n            )\n        return replica_id\n\n    path.parent.mkdir(parents=True, exist_ok=True)\n    replica_id = _mint()\n    tmp = path.with_suffix(\".json.tmp\")\n    tmp.write_text(\n        json.dumps({\"replica_id\": replica_id, \"minted_at_note\": \"RFC 004 step 0\"}, indent=2) + \"\\n\",\n        encoding=\"utf-8\",\n    )\n    os.replace(tmp, path)\n    return replica_id\n","sourceCodeStart":32,"sourceCodeEnd":65,"githubUrl":"https://github.com/MemPalace/mempalace/blob/06cb6987f02610784fefbad4b2bd5d026d164ba6/mempalace/replica.py#L32-L65","documentation":"Error \"{path} holds an invalid replica_id {replica_id!r}; refusing to mint a second identity — restore or delete the file explicitly\" thrown in MemPalace/mempalace.","triggerScenarios":"Thrown at mempalace/replica.py:50 when the library encounters an invalid state.","commonSituations":"Replica identity file contained an invalid id.","solutions":["Restore a valid replica_id or delete the file explicitly to mint a new identity"],"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"}