{"record":{"id":"f26710a37d988877","repo":"astrid-runtime/astrid","slug":"exhausted-unique-names-for-quarantined-leftover-ca","errorCode":null,"errorMessage":"exhausted unique names for quarantined leftover capsule authority receipts","messagePattern":"exhausted unique names for quarantined leftover capsule authority receipts","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-capsule-install/src/authority/leftover.rs","lineNumber":288,"sourceCode":"fn unique_quarantine_path(root: &Path, file_name: &std::ffi::OsStr) -> anyhow::Result<PathBuf> {\n    let encoded = encoded_file_name(file_name);\n    for index in 0_u32..1024 {\n        let candidate = if index == 0 {\n            root.join(&encoded)\n        } else {\n            root.join(format!(\"{encoded}-{index}\"))\n        };\n        match fs::symlink_metadata(&candidate) {\n            Err(error) if error.kind() == std::io::ErrorKind::NotFound => return Ok(candidate),\n            Ok(_) => {},\n            Err(error) => {\n                return Err(error).with_context(|| {\n                    format!(\"inspect quarantine candidate {}\", candidate.display())\n                });\n            },\n        }\n    }\n    bail!(\"exhausted unique names for quarantined leftover capsule authority receipts\")\n}\n\nfn encoded_file_name(name: &std::ffi::OsStr) -> String {\n    const MAX_SAFE_NAME: usize = 80;\n    match name.to_str() {\n        Some(text)\n            if !text.is_empty()\n                && text.len() <= MAX_SAFE_NAME\n                && text != \".\"\n                && text != \"..\"\n                && text\n                    .chars()\n                    .all(|ch| ch.is_ascii_alphanumeric() || matches!(ch, '-' | '_' | '.')) =>\n        {\n            text.to_owned()\n        },\n        _ => format!(\"invalid-{}\", blake3::hash(&os_str_bytes(name)).to_hex()),\n    }","sourceCodeStart":270,"sourceCodeEnd":306,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-capsule-install/src/authority/leftover.rs#L270-L306","documentation":"unique_quarantine_path generates collision-free names for quarantined leftover receipts (encoding the original name and appending a numeric suffix). If it exhausts all candidate names without finding a free path, it bails with this error, refusing to overwrite an existing quarantined file.","triggerScenarios":"Calling quarantine_legacy_authority_receipt → unique_quarantine_path when the quarantine directory already contains files occupying every generated candidate name for a given receipt name (leftover.rs:288) — typically after many repeated quarantines of identically named receipts, or name-length truncation causing collisions.","commonSituations":"Repeated migration attempts quarantining the same-named receipt hundreds of times; a very long original file name forcing heavy truncation in encoded_file_name so all suffix variants collide; corrupted quarantine dir full of stale entries.","solutions":["Clean out stale entries in the migrations quarantine directory (review each file first — they are receipts), then re-run","Manually rename existing quarantined files to shorter names to free candidate names","If the original file name is extremely long, rename the leftover receipt to a short name before re-running the operation","Do not delete or modify quarantined receipts that look unfamiliar; archive the whole quarantine dir and start fresh"],"exampleFix":"// before\n~/.astrid/migrations/quarantine/ filled with receipt.json, receipt.json.1, ... receipt.json.N\nerror: exhausted unique names for quarantined leftover capsule authority receipts\n// after\n$ mkdir ~/astrid-quarantine-archive\n$ mv ~/.astrid/migrations/quarantine/* ~/astrid-quarantine-archive/\n$ astrid migrate  # quarantine slot freed -> succeeds","handlingStrategy":"validation","validationCode":"let qdir = home.migrations_dir().join(\"quarantine\");\nlet collisions = std::fs::read_dir(&qdir)?.filter_map(Result::ok)\n    .filter(|e| e.file_name().to_string_lossy().starts_with(\"receipt\"))\n    .count();\nif collisions > 1000 { anyhow::bail!(\"quarantine dir saturated; clean it first\"); }","typeGuard":null,"tryCatchPattern":"match quarantine_legacy_authority_receipt(&home, &path) {\n    Err(e) if e.to_string().contains(\"exhausted unique names\") => {\n        // archive existing quarantine contents, then retry\n    },\n    other => other?,\n}","preventionTips":["Archive and clear the quarantine directory after reviewing its contents following repeated migrations","Keep original receipt file names short to avoid truncation-driven collisions","Do not leave thousands of stale quarantined receipts in place"],"tags":["filesystem","name-collision","quarantine"],"backgroundTag":"file-already-exists","analyzedSha":"affd8760f44190dbdfbec23403f4c4b642c33112","analyzedAt":"2026-09-09T21:28:12.402Z","contentChangedAt":"2026-09-09T21:28:12.402Z","schemaVersion":2},"datasetVersion":"2026-09-17T15:17:12.973Z"}