{"record":{"id":"ed5fc2dd054d7cfa","repo":"astrid-runtime/astrid","slug":"resolve-capsule-cache-owner-uid-error","errorCode":null,"errorMessage":"resolve capsule cache owner UID: {error}","messagePattern":"resolve capsule cache owner UID: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-kernel/src/capsule_materialization.rs","lineNumber":21,"sourceCode":"use std::path::Path;\n\nuse super::{BoundMaterialization, Kernel, authenticated_ancestor_directories};\n\nimpl Kernel {\n    /// Verify every projected byte against one immutable package snapshot.\n    #[cfg(not(all(target_arch = \"wasm32\", target_os = \"unknown\")))]\n    pub(crate) fn verify_published_materialization(\n        &self,\n        dir: &Path,\n        principal: &astrid_core::principal::PrincipalId,\n        manifest: &astrid_capsule_types::manifest::CapsuleManifest,\n        snapshot: &astrid_storage::CapsulePackageSnapshot,\n    ) -> anyhow::Result<()> {\n        self.validate_published_cache_path(dir, principal, manifest, snapshot)?;\n        let uid = self\n            .principal_directory\n            .uid_for(principal)\n            .map_err(|error| anyhow::anyhow!(\"resolve capsule cache owner UID: {error}\"))?;\n        let verified = astrid_capsule_install::read_verified_durable_package_for_owner(\n            self.principal_store\n                .as_ref()\n                .ok_or_else(|| anyhow::anyhow!(\"durable capsule registry is unavailable\"))?,\n            &astrid_storage::StateOwner::Principal(uid),\n            manifest.package.name.as_str(),\n        )?\n        .ok_or_else(|| anyhow::anyhow!(\"materialized capsule is absent from durable registry\"))?;\n        if verified.snapshot() != snapshot {\n            anyhow::bail!(\"materialized capsule snapshot differs from the caller's publication\");\n        }\n        if verified.manifest().package.name != manifest.package.name\n            || verified.manifest().package.version != manifest.package.version\n        {\n            anyhow::bail!(\"materialized capsule manifest differs from durable registry\");\n        }\n        let manifest_bytes = Self::read_projection_file_nofollow(&dir.join(\"Capsule.toml\"))\n            .map_err(|error| anyhow::anyhow!(\"read materialized capsule manifest: {error:#}\"))?;","sourceCodeStart":3,"sourceCodeEnd":39,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-kernel/src/capsule_materialization.rs#L3-L39","documentation":"While verifying a published capsule materialization, the kernel could not resolve the owning principal to a cache owner UID via principal_directory.uid_for(). The underlying directory error is wrapped with this prefix. Without the UID the durable package cannot be looked up under the correct StateOwner.","triggerScenarios":"verify_published_materialization() calls principal_directory.uid_for(principal) which fails (principal unknown to the directory, directory backend error) and the result is mapped to \"resolve capsule cache owner UID: {error}\".","commonSituations":"The principal was deleted or never registered in the principal directory; the directory store is corrupted or its backend (disk/db) is failing; a stale snapshot references a principal from a previous installation.","solutions":["Read the wrapped inner error to see why uid_for failed (not found vs I/O)","Register/sync the principal in the principal directory before publishing/verifying the capsule","Repair or reinitialize the principal directory store if its backend is failing","Retry after fixing the directory; repair_published_materialization/confirm flows will then pass"],"exampleFix":null,"handlingStrategy":"validation","validationCode":"let uid = principal_directory.uid_for(principal)\n    .map_err(|e| format!(\"principal {} not resolvable to cache UID: {e}\", principal))?;\nif uid == 0 { return Err(\"unresolved UID 0; register principal first\"); }","typeGuard":null,"tryCatchPattern":"match principal_directory.uid_for(principal) {\n    Ok(uid) => proceed_with_verification(uid),\n    Err(e) => log::error!(\"principal {} missing from directory: {e}\", principal),\n}","preventionTips":["Ensure principals are registered in the directory before publishing capsules","Monitor the principal directory backend health","Include UID resolution in pre-publication validation"],"tags":["principal-directory","uid-resolution","storage"],"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-17T15:17:12.973Z"}