Skip to content

fix(opencode-go): accept rate-limited window status instead of discarding the response - #242

Open
moisesfilho wants to merge 1 commit into
slkiser:mainfrom
moisesfilho:fix/issue-241-opencode-go-rate-limited
Open

fix(opencode-go): accept rate-limited window status instead of discarding the response#242
moisesfilho wants to merge 1 commit into
slkiser:mainfrom
moisesfilho:fix/issue-241-opencode-go-rate-limited

Conversation

@moisesfilho

Copy link
Copy Markdown

Summary

Fixes #241 — the OpenCode Go provider reported "Invalid OpenCode Go API" whenever the monthly quota was exhausted, even though the API response was a valid HTTP 200.

Root cause: normalizeWindow in src/lib/opencode-go.ts required every window status to be exactly "ok". When the monthly window is exhausted, the usage API returns status: "rate-limited", so a single non-ok window failed the entire normalizeResponse and the whole payload was discarded.

Changes

  • src/lib/opencode-go.ts: accept "rate-limited" as a valid terminal window state alongside "ok".
  • src/lib/types.ts: widen OpenCodeGoWindow.status to "ok" | "rate-limited".
  • Preserve the raw status in the normalized window so consumers can surface the exhausted state (percentRemaining: 0).
  • Added regression tests:
    • tests/lib.opencode-go.test.ts — rate-limited monthly window normalizes to success.
    • tests/providers.opencode-go.test.ts — provider surfaces status=rate-limited as a valid result.

Verification

  • pnpm verify passes locally (biome, typecheck, build, full suite: 182 files / 2176 tests, four-surface parity, package contents).
  • Manual repro before fix: queryOpenCodeGoQuota returned Invalid OpenCode Go API response: monthly status is not ok: rate-limited. After fix: success: true with monthly.status: "rate-limited", percentRemaining: 0.

Tested against

  • OpenCode production release: 1.18.23
  • Plugin: @slkiser/opencode-quota 4.8.2

…ding the response

When the OpenCode Go monthly quota is exhausted, the usage API returns
status "rate-limited" for that window. normalizeWindow required every
window to be exactly "ok", so a single rate-limited window failed the
entire response and the plugin reported "Invalid OpenCode Go API" even
though the HTTP 200 payload was valid.

- Treat "rate-limited" as a valid terminal window state alongside "ok".
- Preserve the raw status in the normalized window so consumers can
  surface the exhausted state (percentRemaining 0).
- Add regression tests for the rate-limited window at the lib and
  provider layers.

Fixes slkiser#241
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.

OpenCode Go: 'Invalid OpenCode Go API' when monthly window is rate-limited (quota exhausted)

1 participant