From 661446ab50fd270fe634a1d027dbf5a67734d205 Mon Sep 17 00:00:00 2001 From: Gary Zhou Date: Fri, 13 Jun 2025 12:35:21 -0400 Subject: [PATCH] fix: handled the missing keyring error gracefully with a user-friendly message (#2900) --- crates/goose-cli/src/session/builder.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/crates/goose-cli/src/session/builder.rs b/crates/goose-cli/src/session/builder.rs index adc8c491..9a1eb880 100644 --- a/crates/goose-cli/src/session/builder.rs +++ b/crates/goose-cli/src/session/builder.rs @@ -170,8 +170,19 @@ pub async fn build_session(session_config: SessionBuilderConfig) -> Session { // Create the agent let agent: Agent = Agent::new(); - let new_provider = create(&provider_name, model_config).unwrap(); - + let new_provider = match create(&provider_name, model_config) { + Ok(provider) => provider, + Err(e) => { + output::render_error(&format!( + "Error {}.\n\ + Please check your system keychain and run 'goose configure' again.\n\ + If your system is unable to use the keyring, please try setting secret key(s) via environment variables.\n\ + For more info, see: https://block.github.io/goose/docs/troubleshooting/#keychainkeyring-errors", + e + )); + process::exit(1); + } + }; // Keep a reference to the provider for display_session_info let provider_for_display = Arc::clone(&new_provider);