Skip to content

Conversation

@kylecarbs
Copy link
Member

Problem

When using cmux in web mode and encountering API key errors, the UI displays "Message Send Failed - Unknown Error" instead of the proper error message with solutions.

Server logs show the correct error:

sendMessage handler: session returned error {
  workspaceId: '4365d446d4',
  error: { type: 'api_key_not_found', provider: 'openai' }
}

But the UI receives "Unknown Error" because the server was stringifying structured errors.

Solution

The server's IPC adapter was checking if errors were strings and converting objects to "Unknown error". Updated to pass through Result<T, E> types as-is, preserving the full structure including discriminated union types like api_key_not_found.

Browser API now correctly handles Result types and returns them without modification.

Testing

  • Added unit tests for createErrorToast covering all error types
  • Verified that structured errors (api_key_not_found, provider_not_supported, invalid_model_string) create proper toast messages
  • TypeScript compiler confirms Result types flow correctly through the IPC boundary

Generated with cmux

The web server was converting structured SendMessageError objects (like
api_key_not_found) into plain strings, causing the UI to display
'Unknown Error' instead of helpful messages with solutions.

Changes:
- Server now passes through Result<T, E> types as-is instead of
  unwrapping and stringifying error objects
- Browser API updated to handle Result types correctly
- Added unit tests for error toast creation

Before: 'Message Send Failed - Unknown Error'
After: 'API Key Not Found - The openai provider requires an API key'
       with solution: '/providers set openai apiKey YOUR_API_KEY'

Generated with `cmux`
Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Server now only passes through Result types when they fail (have structured
errors). Successful Results and normal return values are wrapped, allowing
the browser API to unwrap all successful responses consistently.

This fixes the issue where providers.list() was receiving { success: true,
data: [...] } instead of just [...], while still preserving structured
errors like api_key_not_found for proper UI display.
@kylecarbs kylecarbs merged commit a19e53a into main Oct 21, 2025
9 checks passed
@kylecarbs kylecarbs deleted the web-errors branch October 21, 2025 17:18
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.

1 participant