{"record":{"id":"fbac3bab2e4e98c1","repo":"tinyhumansai/openhuman","slug":"keychain-set-failed-for-profile-e-detail","errorCode":null,"errorMessage":"Keychain set failed for profile {}: {e} | detail={}","messagePattern":"Keychain set failed for profile (.+?): (.+?) \\| detail=(.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"src/openhuman/security/credentials/profiles.rs","lineNumber":325,"sourceCode":"        format!(\"{KEYCHAIN_AUTH_PREFIX}{profile_id}\")\n    }\n\n    /// Store auth secrets for a profile in the OS keychain.\n    ///\n    /// The secrets are serialized as a compact JSON object so a single\n    /// keychain entry holds all token fields for the profile.\n    fn keychain_store_secrets(&self, profile: &AuthProfile) -> anyhow::Result<()> {\n        let key = self.keychain_key_for_profile(&profile.id);\n        let secrets = serde_json::json!({\n            \"token\": profile.token,\n            \"access_token\": profile.token_set.as_ref().map(|ts| &ts.access_token),\n            \"refresh_token\": profile.token_set.as_ref().and_then(|ts| ts.refresh_token.as_deref()),\n            \"id_token\": profile.token_set.as_ref().and_then(|ts| ts.id_token.as_deref()),\n        });\n        let payload = serde_json::to_string(&secrets)\n            .context(\"Failed to serialize auth secrets for keychain\")?;\n        crate::openhuman::security::keyring::set(&self.user_id, &key, &payload).map_err(|e| {\n            anyhow::anyhow!(\n                \"Keychain set failed for profile {}: {e} | detail={}\",\n                profile.id,\n                e.diagnostic()\n            )\n        })?;\n        log::debug!(\n            \"[auth] keychain_store_secrets stored profile_id={} user_id={}\",\n            profile.id,\n            self.user_id\n        );\n        Ok(())\n    }\n\n    /// Load auth secrets for a profile from the OS keychain.\n    ///\n    /// Returns `None` if no keychain entry exists for the profile.\n    fn keychain_load_secrets(&self, profile_id: &str) -> anyhow::Result<Option<KeychainSecrets>> {\n        let key = self.keychain_key_for_profile(profile_id);","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/tinyhumansai/openhuman/blob/749120085864ce16e0f273c7b86fac7740b39c5b/src/openhuman/security/credentials/profiles.rs#L307-L343","documentation":"Storing an auth profile's secret JSON into the OS keychain failed for that profile id. The keychain write (entry keyed `KEYCHAIN_AUTH_PREFIX + profile_id`) errored — common causes are keychain locked/unavailable, access denied, or on systems without a keychain backend an unwritable filesystem fallback. `{e}` and its diagnostic detail identify the backend cause.","triggerScenarios":"Thrown at src/openhuman/security/credentials/profiles.rs:325 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the keychain/keyring backend is available and unlocked","Verify filesystem permissions for file-backed keyring fallbacks","Read `{e}` diagnostic detail for the backend-specific cause","Retry after unlocking the keychain","Never log the secret payload while diagnosing"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"749120085864ce16e0f273c7b86fac7740b39c5b","analyzedAt":"2026-08-17T21:21:45.363Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}