Skip to content

provider: quota limit surfaced as "not valid JSON" / Authentication instead of the real message #50352

Description

@herjari

Summary

When an OpenCode Go account exceeds its weekly model usage limit, requests fail with a misleading error: AI.Error.Authentication: Error from provider (Console Go): Upstream request failed: [server_error] Upstream response was not valid JSON. The real, actionable message (Weekly usage limit reached… enable usage from your available balance…) only appears in the server log, and the failure is classified as an authentication/JSON error instead of a quota/rate-limit error. Affected sessions look broken and the actual cause is hard to find.

Environment

  • opencode version: 2.0.11 (OpenCode Desktop; bundled CLI reports opencode v2.0.11). The separately installed npm CLI is V1 1.18.18.
  • OS: Windows 11 (NT 10.0.26200)
  • Terminal: OpenCode Desktop app on Windows (no TUI)
  • Shell: cmd.exe / PowerShell
  • Install/channel: Desktop release (ai.opencode.desktop), bundled CLI 2.0.11
  • Active plugins: a local gates.ts plugin file exists in the global config plugins/ directory; unrelated to this issue.
  • opencode service status: http://127.0.0.1:49374

Reproduction

  1. Use a provider account (OpenCode Go) whose weekly usage limit for a model is exhausted.
  2. Send a prompt to any session using that provider/model (e.g. opencode-go/<model>#max).
  3. The session fails with AI.Error.Authentication: Error from provider (Console Go): Upstream request failed: [server_error] Upstream response was not valid JSON.
  4. In ~/.local/share/opencode/log/opencode.log, the same time window shows the real cause: AI.Error: Weekly usage limit reached. Resets in 1hr 13min. To continue using this model now, enable usage from your available balance: https://opencode.ai/....

Expected Behavior

The client should surface the provider's actual message (weekly usage limit / quota exhausted) and classify it as a quota or rate-limit error, not as an authentication failure or invalid JSON.

Actual Behavior

AI.Error: Error from provider (Console Go): Upstream request failed: [server_error] Upstream response was not valid JSON
  [cause]: AI.Error.Authentication: Error from provider (Console Go): Upstream request failed: [server_error] Upstream response was not valid JSON

The quota message is only visible in the log. Around the same window the log also shows: WARN failed to load OpenCode provider config cause="HttpClientError: StatusCode: non 2xx status code (401 GET https://opencode.ai/console/api/v2/config)".

Additional Context

  • Frequency: intermittent while the limit is active (some requests succeed, most fail), across multiple sessions.
  • Impact: the UI shows an auth/parse error; users cannot tell the account is out of quota and retries look like random flakiness.
  • Workaround: switch to another credential/account or provider, enable balance usage, or wait for the weekly reset.
  • Likely cause: the provider's quota response body is not JSON and the client's error mapping wraps it as AI.Error.Authentication.
  • Sanitized log lines (credentials and session ids removed):
    • level=ERROR message="Failed to drain Session" cause="AI.Error: Error from provider (Console Go): Upstream request failed: [server_error] Upstream response was not valid JSON"
    • level=ERROR message="Failed to drain Session" cause="AI.Error: Weekly usage limit reached. Resets in 1hr 13min. To continue using this model now, enable usage from your available balance: https://opencode.ai/..."

Activity

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

Metadata

Metadata

Assignees

No one assigned

    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