fix(opencode-go): accept rate-limited window status instead of discarding the response - #242
Open
moisesfilho wants to merge 1 commit into
Open
Conversation
…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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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:
normalizeWindowinsrc/lib/opencode-go.tsrequired every windowstatusto be exactly"ok". When the monthly window is exhausted, the usage API returnsstatus: "rate-limited", so a single non-okwindow failed the entirenormalizeResponseand 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: widenOpenCodeGoWindow.statusto"ok" | "rate-limited".percentRemaining: 0).tests/lib.opencode-go.test.ts— rate-limited monthly window normalizes to success.tests/providers.opencode-go.test.ts— provider surfacesstatus=rate-limitedas a valid result.Verification
pnpm verifypasses locally (biome, typecheck, build, full suite: 182 files / 2176 tests, four-surface parity, package contents).queryOpenCodeGoQuotareturnedInvalid OpenCode Go API response: monthly status is not ok: rate-limited. After fix:success: truewithmonthly.status: "rate-limited",percentRemaining: 0.Tested against