{"record":{"id":"36847477e53469a2","repo":"astrid-runtime/astrid","slug":"cannot-load-capsule-id-for-unadmitted-principa","errorCode":null,"errorMessage":"cannot load capsule '{id}' for unadmitted principal '{principal}': {error}","messagePattern":"cannot load capsule '(.+?)' for unadmitted principal '(.+?)': (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/astrid-kernel/src/lib.rs","lineNumber":1868,"sourceCode":"            capsule.publish();\n        }\n        Ok(())\n    }\n\n    fn runtime_principal_uid(\n        &self,\n        system_runtime: bool,\n        principal: &PrincipalId,\n        id: &astrid_capsule_types::CapsuleId,\n    ) -> Result<Option<astrid_core::identity::PrincipalUid>, anyhow::Error> {\n        if system_runtime {\n            return Ok(None);\n        }\n        self.principal_directory\n            .uid_for(principal)\n            .map(Some)\n            .map_err(|error| {\n                anyhow::anyhow!(\n                    \"cannot load capsule '{id}' for unadmitted principal '{principal}': {error}\"\n                )\n            })\n    }\n\n    /// Build and load one mutable runtime. `Some(principal)` installs that\n    /// principal's concrete KV/home/env authority from construction onward.\n    /// `None` is reserved for an explicitly classified `SystemResident` service\n    /// and receives a neutral system namespace rather than `default` authority.\n    ///\n    /// # Errors\n    ///\n    /// Returns an error if the capsule cannot be created, the KV scope cannot be\n    /// built, or `capsule.load` fails.\n    #[cfg(not(all(target_arch = \"wasm32\", target_os = \"unknown\")))]\n    async fn build_capsule_runtime(\n        &self,\n        manifest: astrid_capsule_types::manifest::CapsuleManifest,","sourceCodeStart":1850,"sourceCodeEnd":1886,"githubUrl":"https://github.com/astrid-runtime/astrid/blob/affd8760f44190dbdfbec23403f4c4b642c33112/crates/astrid-kernel/src/lib.rs#L1850-L1886","documentation":"Thrown when loading a capsule requires resolving the owner's UID via `principal_directory.uid_for`, and that lookup fails for the given principal. The message names the capsule id and principal, indicating the principal is not admitted (or the directory lookup failed), so the capsule cannot be loaded for them. The directory error is embedded as `{error}`.","triggerScenarios":"Calling the capsule-load API with a principal that was never admitted to the principal_directory, or whose directory lookup errors (removed principal, backend failure).","commonSituations":"Loading a capsule under a different identity than the one that owns it; principal revoked after admission; directory storage misconfiguration or corruption; passing a raw/invalid principal identifier.","solutions":["Admit the principal via the principal_directory before loading its capsules.","Confirm you are passing the owning principal, not a different authenticated identity.","Check the embedded `{error}` to distinguish unadmitted principal from backend failure.","If the principal was revoked, re-run admission or use the current owner's identity."],"exampleFix":"// before\nlet view = kernel.load_capsule(&id, &some_principal)?;\n// after\nlet admitted = kernel.principal_directory().uid_for(&some_principal).is_ok();\nanyhow::ensure!(admitted, \"principal must be admitted before loading capsule {id}\");\nlet view = kernel.load_capsule(&id, &some_principal)?;","handlingStrategy":"validation","validationCode":"// guard before loading\nif principal_directory.uid_for(&principal).is_err() {\n    anyhow::bail!(\"admit principal {principal:?} before loading capsule '{id}'\");\n}","typeGuard":"fn can_load(dir: &PrincipalDirectory, p: &Principal) -> bool { dir.uid_for(p).is_ok() }","tryCatchPattern":"match load_capsule(id, principal) {\n    Err(e) if e.to_string().contains(\"unadmitted principal\") => admit_then_retry(principal)?,\n    other => other,\n}","preventionTips":["Complete principal admission before any capsule load.","Use the owning principal's identity for capsule operations.","Re-check admission after revocation or identity changes."],"tags":["authentication","rust","kernel","capsule"],"backgroundTag":"user-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"}