Skip to content

fix: replace panics with user-friendly errors in CLI session builder#7901

Merged
DOsinga merged 2 commits intoblock:mainfrom
jeffa-block:jeffa/fix-cli-panic-missing-provider
Mar 26, 2026
Merged

fix: replace panics with user-friendly errors in CLI session builder#7901
DOsinga merged 2 commits intoblock:mainfrom
jeffa-block:jeffa/fix-cli-panic-missing-provider

Conversation

@jeffa-block
Copy link
Copy Markdown
Contributor

Summary

resolve_provider_and_model() and resolve_session_id() used .expect() which causes a raw panic with a full Rust stack trace when no provider or model is configured. Users see a frightening backtrace instead of a helpful message.

Changes

Replace all 7 .expect() calls in builder.rs with .unwrap_or_else() that prints a styled error via output::render_error() and exits cleanly. This matches the existing error handling pattern already used in the same file (e.g. ModelConfig::new() on line 390).

Before

thread 'main' panicked at crates/goose-cli/src/session/builder.rs:362:10:
No provider configured. Run 'goose configure' first
stack backtrace:
   0: std::sys::backtrace::...
   ...

After

  error: No provider configured. Run 'goose configure' first.

Converted calls

  1. Missing provider name → styled error + exit
  2. Missing model name → styled error + exit
  3. current_dir() failure → styled error + exit
  4. Session creation failure → styled error + exit
  5. Working directory resolution → styled error + exit
  6. User input failure → styled error + exit
  7. System prompt file read failure → styled error with filename + exit

Fixes #7889

`resolve_provider_and_model()` used `.expect()` which causes a raw
panic with a stack trace when no provider or model is configured.
Users see a frightening Rust backtrace instead of a helpful message.

Replace all 7 `.expect()` calls in builder.rs with
`.unwrap_or_else()` that prints a styled error via
`output::render_error()` and exits cleanly.  This matches the
existing error handling pattern already used in the same file
(e.g. line 390).

Fixes block#7889
@DOsinga DOsinga marked this pull request as ready for review March 26, 2026 21:22
Copy link
Copy Markdown
Collaborator

@DOsinga DOsinga left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@DOsinga DOsinga added this pull request to the merge queue Mar 26, 2026
Merged via the queue into block:main with commit 907c661 Mar 26, 2026
21 checks passed
michaelneale added a commit that referenced this pull request Mar 26, 2026
* main: (337 commits)
  fix: replace panics with user-friendly errors in CLI session builder (#7901)
  fix: read GOOSE_CONTEXT_LIMIT from config.yaml, not just env vars (#7900)
  fix: deliver truncation notice as separate content block (#7899)
  fix: use platform-appropriate commands in developer extension instructions (#7898)
  fix: replace any with proper SVG types in icon components (#7873)
  chore: remove debug console.log statements, stale comments, and dead code (#8142)
  feat: Gemini OAuth provider (#8129)
  chore(deps): bump picomatch from 2.3.1 to 2.3.2 in /documentation (#8123)
  feat: show installed skills in UI (#7910)
  fix(deps): gate keyring platform features behind target-specific deps (#8039)
  chore(deps): bump yaml from 2.8.2 to 2.8.3 in /evals/open-model-gym/suite (#8124)
  fix: strip message wrapper in CLI session title generation (#7996)
  fix(providers): fall back to configured models when models endpoint fetch fails (#7530)
  chore(deps): bump brace-expansion from 5.0.3 to 5.0.5 in /evals/open-model-gym/suite (#8139)
  fix: prevent Ollama provider from hanging on tool-calling requests (#7723)
  fix: VMware Tanzu Platform provider - bug fixes, streaming, UI improvements (#8126)
  feat: allow GOOSE_CLI_SHOW_THINKING to be set in config.yaml (#8097)
  fix: GitHub Copilot auth fails to open browser in Desktop app (#6957) (#8019)
  fix(ci): produce .tar.gz archives for Zed ACP registry compatibility (#8054)
  feat: add GOOSE_SHOW_FULL_OUTPUT config to disable tool output truncation (#7919)
  ...

# Conflicts:
#	crates/goose/src/providers/formats/openai.rs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"goose session" fails to find configured provider

2 participants