From f46ac1ce711f716ccf68a0f812fa1ca9593bb83a Mon Sep 17 00:00:00 2001 From: Gary <117497221+GaryZhous@users.noreply.github.com> Date: Fri, 13 Jun 2025 00:50:20 -0400 Subject: [PATCH] fix: handled the missing keyring error gracefully with a user-friendly message --- 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 adc8c4915f45..9a1eb880cdff 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);