{"record":{"id":"ed809f44ce6efc13","repo":"unicity-aos/aos-ce","slug":"failed-to-preserve-imported-activation-state-error","errorCode":null,"errorMessage":"failed to preserve imported activation state: {error}","messagePattern":"failed to preserve imported activation state: (.+?)","errorType":"validation","errorClass":"io::Error","httpStatus":null,"severity":"error","filePath":"crates/unicity-aos-bootstrap/src/migration.rs","lineNumber":272,"sourceCode":"            \"a previous migration staging directory could not be recovered automatically\",\n        );\n    }\n\n    let result = (|| {\n        create_private_dir(&staging)?;\n        let mut entries = Vec::new();\n        copy_etc_state(&source, &staging, &mut entries)?;\n        for name in PERSISTENT_TOP_LEVEL {\n            copy_if_present(\n                &source.join(name),\n                &staging.join(name),\n                Path::new(name),\n                &mut entries,\n            )?;\n        }\n        copy_wasm_blobs(&source.join(\"bin\"), &staging.join(\"bin\"), &mut entries)?;\n        archive_inactive_activation_state(&staging, &mut entries).map_err(|error| {\n            io::Error::new(\n                error.kind(),\n                format!(\"failed to preserve imported activation state: {error}\"),\n            )\n        })?;\n        ensure_no_ephemeral_data(&staging).map_err(|error| {\n            io::Error::new(\n                error.kind(),\n                format!(\"failed to validate ephemeral state exclusion: {error}\"),\n            )\n        })?;\n        entries.sort_by(|left, right| left.path.cmp(&right.path));\n        let legacy_distros = legacy_distros(&staging).map_err(|error| {\n            io::Error::new(\n                error.kind(),\n                format!(\"failed to inspect imported distro locks: {error}\"),\n            )\n        })?;\n        let receipt = Receipt {","sourceCodeStart":254,"sourceCodeEnd":290,"githubUrl":"https://github.com/unicity-aos/aos-ce/blob/f6f22024fb1e8d122f28a1b4a9f75aee448ae839/crates/unicity-aos-bootstrap/src/migration.rs#L254-L290","documentation":"`migrate_runtime` calls `archive_inactive_activation_state` on the staging copy of the imported runtime and wraps any failure in an `io::Error` preserving the original kind, prefixed with \"failed to preserve imported activation state\". This means inactive activation-state homes could not be archived — typically due to I/O errors or invalid names encountered while walking the imported state.","triggerScenarios":"Any error surfaced from `archive_inactive_activation_state` while iterating `homes`/capsule directories during `migrate_runtime` — e.g. unreadable directories, permission failures, or the non-UTF-8 name errors (errors 38/39).","commonSituations":"Importing from a source with restrictive permissions on principal home directories, a partially-corrupted activation state, or filesystems that return errors on read_dir during copy.","solutions":["Read the wrapped inner error in the message after the prefix — it names the actual failing operation (path, permission, encoding) to fix.","Fix permissions on the source runtime's `homes`/activation-state directories so they are readable by the migrating user.","Rename any non-UTF-8 file/directory names under the imported principal homes and capsule installations before migrating.","Re-create or repair the source activation state (e.g. by re-syncing from the live runtime) if directories are corrupted, then retry."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"check_source_readable(source.join(\"state/homes\"))?;\ncheck_all_names_utf8(source.join(\"state/homes\"))?;","typeGuard":null,"tryCatchPattern":"if let Some(io_err) = err.downcast_ref::<io::Error>() {\n    let inner = io_err.to_string();\n    if let Some(inner_msg) = inner.strip_prefix(\"failed to preserve imported activation state: \") {\n        eprintln!(\"underlying cause: {inner_msg}\");\n    }\n}","preventionTips":["Run the migration as a user with read access to all activation-state directories.","Ensure all names under homes/ and capsule dirs are UTF-8 before migrating.","Stop the source runtime so state is not mutated during archiving."],"tags":["migration","filesystem","io","rust"],"backgroundTag":"file-read-failed","analyzedSha":"f6f22024fb1e8d122f28a1b4a9f75aee448ae839","analyzedAt":"2026-09-13T03:04:44.565Z","contentChangedAt":"2026-09-13T03:04:44.565Z","schemaVersion":2},"datasetVersion":"2026-09-16T09:17:16.951Z"}