openai/codex · error · anyhow::Error

failed to load secrets key from keyring for {account}

Error message

failed to load secrets key from keyring for {account}

What it means

Error "failed to load secrets key from keyring for {account}" thrown in openai/codex.

Source

Thrown at codex-rs/secrets/src/local.rs:242

        let path = self.secrets_path();
        write_file_atomically(&path, &ciphertext)?;
        if self.namespace == LocalSecretsNamespace::McpOAuth {
            let mut cache = MCP_OAUTH_CACHE
                .lock()
                .unwrap_or_else(PoisonError::into_inner);
            if cache.as_ref().is_some_and(|cached| cached.path == path) {
                *cache = None;
            }
        }
        Ok(())
    }

    fn load_or_create_passphrase(&self) -> Result<SecretString> {
        let account = compute_keyring_account(&self.codex_home);
        let loaded = self
            .keyring_store
            .load(keyring_service(), &account)
            .map_err(|err| anyhow::anyhow!(err.message()))
            .with_context(|| format!("failed to load secrets key from keyring for {account}"))?;
        match loaded {
            Some(existing) => Ok(SecretString::from(existing)),
            None => {
                // Generate a high-entropy key and persist it in the OS keyring.
                // This keeps secrets out of plaintext config while remaining
                // fully local/offline for the MVP.
                let generated = generate_passphrase()?;
                self.keyring_store
                    .save(keyring_service(), &account, generated.expose_secret())
                    .map_err(|err| anyhow::anyhow!(err.message()))
                    .context("failed to persist secrets key in keyring")?;
                Ok(generated)
            }
        }
    }
}

View on GitHub (pinned to 339751715c)

When it happens

Trigger: Thrown at codex-rs/secrets/src/local.rs:242 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of openai/codex@339751715c (2026-08-25). Data as JSON: /api/errors/da0cb73b5d501f5b. Report an issue: GitHub.