{"record":{"id":"8c7e96a19f74b622","repo":"openai/codex","slug":"failed-to-write-oauth-tokens-to-keyring","errorCode":null,"errorMessage":"failed to write OAuth tokens to keyring: {}","messagePattern":"failed to write OAuth tokens to keyring: (.+?)","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"codex-rs/rmcp-client/src/oauth.rs","lineNumber":485,"sourceCode":"}\n\nfn save_oauth_tokens_to_direct_keyring<K: KeyringStore>(\n    keyring_store: &K,\n    server_name: &str,\n    tokens: &StoredOAuthTokens,\n) -> Result<()> {\n    let serialized = serde_json::to_string(tokens).context(\"failed to serialize OAuth tokens\")?;\n\n    let key = compute_store_key(server_name, &tokens.url)?;\n    match keyring_store.save(KEYRING_SERVICE, &key, &serialized) {\n        Ok(()) => Ok(()),\n        Err(error) => {\n            let message = format!(\n                \"failed to write OAuth tokens to keyring: {}\",\n                error.message()\n            );\n            warn!(\"{message}\");\n            Err(Error::new(error.into_error()).context(message))\n        }\n    }\n}\n\n/// Saves one credential while holding the Secrets aggregate-store lock across the mutation.\nfn save_oauth_tokens_to_secrets_keyring<K: KeyringStore + Clone + 'static>(\n    keyring_store: &K,\n    server_name: &str,\n    tokens: &StoredOAuthTokens,\n) -> Result<()> {\n    let serialized = serde_json::to_string(tokens).context(\"failed to serialize OAuth tokens\")?;\n    let _store_lock = OAuthStoreLock::acquire_for_write(OAuthStore::Secrets)?;\n    save_oauth_tokens_to_secrets_keyring_with_lock_held(\n        keyring_store,\n        server_name,\n        tokens,\n        &serialized,\n    )","sourceCodeStart":467,"sourceCodeEnd":503,"githubUrl":"https://github.com/openai/codex/blob/339751715c64496cb86246bfb3935f40e309dd3d/codex-rs/rmcp-client/src/oauth.rs#L467-L503","documentation":"Error \"failed to write OAuth tokens to keyring: {}\" thrown in openai/codex.","triggerScenarios":"Thrown at codex-rs/rmcp-client/src/oauth.rs:485 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"339751715c64496cb86246bfb3935f40e309dd3d","analyzedAt":"2026-08-25T05:35:09.876Z","schemaVersion":2},"datasetVersion":"2026-08-25T06:17:31.827Z"}