Skip to content

fix(app): return error when conversation is not found#2852

Merged
tusharmath merged 3 commits intomainfrom
conversation-initialization-error
Apr 6, 2026
Merged

fix(app): return error when conversation is not found#2852
tusharmath merged 3 commits intomainfrom
conversation-initialization-error

Conversation

@tusharmath
Copy link
Copy Markdown
Collaborator

@tusharmath tusharmath commented Apr 5, 2026

Summary

Return a proper error when a conversation is not found during chat initialization instead of panicking, and clean up stale/experimental code that accumulated around OAuth, Bedrock, and dependency management.

Context

The previous code used unwrap_or_default().expect(...) when looking up a conversation, which would panic with a confusing message if the conversation was missing. This PR replaces that with proper anyhow error propagation so callers receive a clean, descriptive error.

Alongside the bug fix, this PR removes several features and files that are no longer needed: the localhost OAuth callback server (and its tiny_http dependency), the Bedrock SanitizeToolIds transformer, the google_ai_studio provider, and the hex crate (replaced by format!("{:x}", ...) directly). The Bedrock provider model list is also restored to the stable set of GA models.

Changes

  • Bug fix: find_conversation now propagates errors properly using ? and ok_or_else, returning "conversation {id} not found" instead of panicking
  • Removed LocalhostOAuthCallbackServer: Deleted oauth_callback.rs (~526 lines) and removed the tiny_http dependency — the OAuth flow now always prompts the user to paste the authorization code
  • Removed SanitizeToolIds Bedrock transformer: Deleted bedrock_sanitize_ids.rs (~269 lines) and its regex dependency from forge_repo
  • Removed google_ai_studio provider: Cleaned up the ProviderId constant, display name mapping, from_str parsing, and related tests
  • Removed id_token from OAuthTokenResponse: Field and associated enrichment logic for Codex OAuth removed; extract_chatgpt_account_id is now inlined directly where needed (device flow only)
  • Replaced hex crate: SHA-256 hex encoding now uses format!("{:x}", hasher.finalize()) in both forge_app and forge_fs
  • Dependency downgrades: sha2 pinned back to 0.10, similar to 2.4, rustyline to 17.0.2, posthog-rs to 0.4.7, toml_edit to 0.22 — aligning with upstream stable versions
  • Bedrock provider list: Restored to the stable set of GA models (Titan, Anthropic Claude, Cohere, Meta Llama families), removing pre-release/experimental entries

Key Implementation Details

The conversation lookup change is minimal but impactful: unwrap_or_default().expect(...) was replaced with ? chaining through ok_or_else(|| anyhow::anyhow!("conversation {} not found", id)). This ensures any missing conversation surfaces as a structured anyhow::Error rather than a panic, which is then handled correctly by the caller.

The enrich_codex_oauth_credential helper was removed because the id_token field (its primary input) was removed from OAuthTokenResponse. The Codex device flow still extracts chatgpt_account_id from the access token directly.

Testing

# Run crate-level tests
cargo insta test --accept

# Verify the conversation not-found error surfaces correctly
cargo check -p forge_app

Links

@github-actions github-actions bot added the type: fix Iterations on existing features or infrastructure. label Apr 5, 2026
@tusharmath tusharmath force-pushed the conversation-initialization-error branch from e188476 to 79c08d9 Compare April 6, 2026 12:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: fix Iterations on existing features or infrastructure.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant