{"record":{"id":"4548871679fbff06","repo":"astrid-runtime/astrid","slug":"invaliddata-454887","errorCode":"InvalidData","errorMessage":"legacy audit source for {alias} was inventoried but is missing: {}","messagePattern":"legacy audit source for (.+?) was inventoried but is missing: (.+?)","errorType":"validation","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"crates/astrid-kernel/src/legacy_migration_barrier/legacy_audit.rs","lineNumber":39,"sourceCode":"    home: &AstridHome,\n    alias: &PrincipalId,\n    source: Option<&SourceIdentity>,\n) -> io::Result<()> {\n    let Some(source) = source else {\n        return Ok(());\n    };\n    if !source.present {\n        return Ok(());\n    }\n    let path = home.principal_home(alias).audit_dir();\n    if source.entries == SourceCount::ZERO {\n        if path_exists(&path)? {\n            retire_empty_directory(&path)?;\n        }\n        return Ok(());\n    }\n    if !path_exists(&path)? {\n        return Err(io::Error::new(\n            io::ErrorKind::InvalidData,\n            format!(\n                \"legacy audit source for {alias} was inventoried but is missing: {}\",\n                path.display()\n            ),\n        ));\n    }\n    quarantine_audit_tree(home, alias, &path)\n}\n\nfn quarantine_audit_tree(home: &AstridHome, alias: &PrincipalId, source: &Path) -> io::Result<()> {\n    let quarantine_root = home.migrations_dir().join(QUARANTINE_DIR);\n    astrid_core::platform_fs::ensure_private_directory(&quarantine_root)?;\n    let destination = unique_destination(&quarantine_root, alias.as_str())?;\n    fs::rename(source, &destination).map_err(|error| {\n        io::Error::new(\n            error.kind(),\n            format!(","sourceCodeStart":21,"sourceCodeEnd":57,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-kernel/src/legacy_migration_barrier/legacy_audit.rs#L21-L57","documentation":"The legacy audit rejection pass keeps an inventory of legacy audit sources per alias. If an alias was inventoried as a supported-but-handled source yet its path no longer exists on disk when reject_unsupported_sources runs, this InvalidData error is raised — the accounting and the filesystem disagree.","triggerScenarios":"handle_non_default_audit_source (called by reject_unsupported_sources) checks path_exists(&path) for an inventoried legacy audit source; the path is missing, so the error is thrown with the alias and path.","commonSituations":"The legacy audit directory was deleted by cleanup between inventory and the rejection pass; the migration state file references an alias from a different machine/home; a partial restore removed audit trees but kept the inventory.","solutions":["Restore the missing legacy audit directory for that alias, or","Rebuild/clear the migration inventory so it no longer lists the missing source, then re-run","Check whether another process deleted the audit tree and serialize cleanup with migration","If the tree was already intentionally migrated, complete that alias's migration state so this pass skips it"],"exampleFix":"// before: inventory says alias has a legacy source, but dir was deleted\n// after: re-inventory before rejecting unsupported sources\nlet sources = inventory_legacy_sources(&home)?;\nreject_unsupported_sources(&home, &sources)?;","handlingStrategy":"validation","validationCode":"if !path_exists(&audit_path_for(alias))? {\n    // rebuild inventory or skip the alias before calling reject_unsupported_sources\n}","typeGuard":null,"tryCatchPattern":"if let Err(e) = reject_unsupported_sources(&home, &sources) {\n    if e.to_string().contains(\"was inventoried but is missing\") {\n        let fresh = inventory_legacy_sources(&home)?;\n        reject_unsupported_sources(&home, &fresh)?;\n    }\n}","preventionTips":["Rebuild the source inventory on every migration run","Prevent cleanup jobs from deleting legacy trees mid-migration","Keep inventory state on the same machine/home as the files it references"],"tags":["filesystem","audit","migration","inconsistent-state"],"backgroundTag":"resource-not-found","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"}