{"record":{"id":"559680dbee01da7d","repo":"astrid-runtime/astrid","slug":"quarantined-capsule-authority-bytes-changed","errorCode":null,"errorMessage":"quarantined capsule authority bytes changed: {}","messagePattern":"quarantined capsule authority bytes changed: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-capsule-install/src/authority/leftover.rs","lineNumber":131,"sourceCode":"    let destination = unique_quarantine_path(&quarantine_root, file_name)?;\n    fs::rename(path, &destination).with_context(|| {\n        format!(\n            \"quarantine leftover capsule authority {} to {}\",\n            path.display(),\n            destination.display()\n        )\n    })?;\n    if let Some(parent) = path.parent() {\n        sync_authority_directory(parent)?;\n    }\n    let preserved = fs::read(&destination).with_context(|| {\n        format!(\n            \"read quarantined capsule authority {}\",\n            destination.display()\n        )\n    })?;\n    if preserved != bytes {\n        bail!(\n            \"quarantined capsule authority bytes changed: {}\",\n            destination.display()\n        );\n    }\n    tracing::warn!(\n        leftover = %path.display(),\n        destination = %destination.display(),\n        \"quarantined unmatched leftover capsule authority receipt\"\n    );\n    Ok(destination)\n}\n\n/// Unlink one leftover receipt after its durable ingest has been verified.\npub(crate) fn retire_unmatched_authority_receipt_file(\n    path: &Path,\n    expected_bytes: &[u8],\n) -> anyhow::Result<()> {\n    let metadata = fs::symlink_metadata(path).with_context(|| {","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-capsule-install/src/authority/leftover.rs#L113-L149","documentation":"quarantine_legacy_authority_receipt moves a leftover legacy authority receipt into a quarantine directory, then re-reads the moved file and compares its bytes to what was read before the rename. If the quarantined copy differs from the original bytes, the library throws this error because the atomic preservation of the receipt could not be verified — the data being archived may be corrupted or was modified mid-operation.","triggerScenarios":"Calling retire_one_leftover → quarantine_legacy_authority_receipt on a receipt whose content changes between the pre-rename fs::read and the post-rename read of the destination (destination in leftover.rs:124-135). This happens if another process writes to the file during the rename, the filesystem (e.g. network mount) corrupts or alters data on move, or an editor/sync daemon (Dropbox, antivirus quarantine) rewrites the file.","commonSituations":"Running capsule install/migration while a cloud-sync or antivirus service watches the migrations directory and rewrites files; a flaky NFS/FUSE mount where rename is not byte-stable; concurrent instances of the tool racing on the same home directory.","solutions":["Re-run the operation; transient concurrent modification is the most common cause and a retry on a quiet system usually succeeds","Stop any process that could touch the home directory (cloud sync, antivirus scans, another running instance) before retrying","Inspect the quarantined file at the reported destination and manually compare it with a backup; if intact, it is safe","Check filesystem health (fsck / mount type); move the home dir to a local, non-synced filesystem if corruption recurs"],"exampleFix":"// before: running migration with live sync daemon\n$ astrid migrate  # -> quarantined capsule authority bytes changed: ~/.astrid/migrations/quarantine/receipt.json\n// after\n$ systemctl --user stop dropbox\n$ astrid migrate  # succeeds","handlingStrategy":"try-catch","validationCode":"let bytes = std::fs::read(&path)?;\nif !path.is_file() { anyhow::bail!(\"not a regular file: {}\", path.display()); }\n// ensure no other writer holds it open where possible (e.g. flock the file)","typeGuard":"fn is_stable_regular_file(p: &Path) -> bool {\n    std::fs::symlink_metadata(p).map(|m| m.is_file()).unwrap_or(false)\n}","tryCatchPattern":"match quarantine_legacy_authority_receipt(&home, &path) {\n    Ok(dest) => info!(\"quarantined to {}\", dest.display()),\n    Err(e) if e.to_string().contains(\"bytes changed\") => {\n        warn!(\"concurrent modification during quarantine; retrying once\");\n        // stop sync/AV writers, then retry\n    },\n    Err(e) => return Err(e),\n}","preventionTips":["Pause cloud-sync/antivirus services that watch the astrid home directory during migrations","Run only one instance of the tool at a time against a given home","Use a local filesystem (not NFS/FUSE) for the home directory","Re-run the operation rather than hand-editing quarantined files"],"tags":["filesystem","integrity-check","concurrency"],"backgroundTag":"checksum-mismatch","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}