Skip to content

Provider errors shaped like OpenAI { error: { message } } skip the real message #36410

Description

@AayushMainali-Github

Description

When a provider returns JSON like OpenAI's error shape:

{
  "error": {
    "message": "Rate limit exceeded",
    "type": "rate_limit_error"
  }
}

OpenCode tries to pull a useful string out of the body in packages/opencode/src/provider/error.ts with:

body.message || body.error || body.error?.message

body.error is an object, so it wins before body.error.message is ever read. The typeof errMsg === "string" check then fails, and the real message is dropped. Users often get a generic status line or a raw JSON dump instead of "Rate limit exceeded".

Plugins

None

OpenCode version

current dev

Steps to reproduce

  1. Open packages/opencode/src/provider/error.ts around the responseBody JSON parse
  2. Note the extraction order: body.message || body.error || body.error?.message
  3. For a body of { "error": { "message": "Rate limit exceeded" } }, body.error is truthy and not a string, so the message is never used
  4. Same class of response from OpenAI-compatible providers shows up as a vague/HTTP-only error in the UI instead of the provider message

Screenshot and/or share link

No response

Operating System

any

Terminal

any

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions