Skip to content

fix(coding-plans): classify missing MiniMax quota rows as an inactive plan - #6215

Merged
iscekic merged 3 commits into
mainfrom
debug/minimax-coding-plan-2056
Sep 16, 2026
Merged

iscekic merged 3 commits into
mainfrom
debug/minimax-coding-plan-2056

Conversation

@iscekic

@iscekic iscekic commented Sep 16, 2026 •

Copy link
Copy Markdown
Collaborator

Finding

The first diagnosis was wrong. A live probe with the production read replica and BYOK_ENCRYPTION_KEY shows the actual shape:

  • All 28 affected subscriptions return HTTP 200 {"model_remains":null,"base_resp":{"status_code":0}} from GET /v1/token_plan/remains.
  • www.minimax.io and api.minimax.io return identical data. The endpoint was never the problem.
  • Working keys return model_remains with a general row and percent fields, so the aggregate name and the percent fields are unchanged.
  • 25 of the 28 affected subscription users also produced MiniMax HTTP 429 / code 2056 events in the last 4 days.

MiniMax holds no quota rows for these keys and rejects inference on them. That part is upstream.

Kilo defect

model_remains used .optional(), which accepts undefined but not null. Every affected lookup therefore threw invalid_response, and codingPlans.getUsage returned 502. The page showed "Current quota is temporarily unavailable".

Change

  • Accept model_remains: null.
  • Report an empty row set with the new subscription_inactive error code, so logs separate a provider plan problem from a parse failure.

The endpoint, aggregate row selection, and percent handling are unchanged.

Verification

  • npx jest src/lib/coding-plans src/routers/coding-plans-router.test.ts: 9 suites, 122 tests pass.
  • tsgo --noEmit exit 0. oxlint clean. oxfmt applied.
  • Live evidence: 28/29 affected keys returned model_remains: null; 7/8 sampled unassigned inventory keys returned active plans.

Remaining work

This change does not restore service, because MiniMax has no usable plan for the affected keys. Unblocking them needs key replacement and a MiniMax escalation. Replacement is viable: 7 of 8 sampled unassigned inventory keys still hold an active plan.

MiniMax stopped returning a parseable `general` row on the gateway host for
managed Token Plan keys on 2026-09-13. Every usage lookup then threw
`invalid_response`, the router returned 502, and the subscription page showed
"Current quota is temporarily unavailable".

Query the documented `www.minimax.io` host first and keep `api.minimax.io` as a
fallback. Accept the aggregate pool when MiniMax reports it as `MiniMax-M*`, and
clamp an out-of-range remaining percent instead of discarding the response.
@iscekic iscekic self-assigned this Sep 16, 2026
Comment thread apps/web/src/lib/coding-plans/minimax-usage.ts Outdated
Comment thread apps/web/src/lib/coding-plans/minimax-usage.test.ts Outdated
@kilo-code-bot

kilo-code-bot Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Code Review Summary

Status: No Issues Found | Recommendation: Merge

Files Reviewed (3 files)
  • apps/web/src/lib/coding-plans/minimax-usage.ts
  • apps/web/src/lib/coding-plans/minimax-usage.test.ts
  • apps/web/src/lib/coding-plans/usage-contract.ts
Previous Review Summaries (2 snapshots, latest commit 012b6d2)

Current summary above is authoritative. Previous snapshots are kept for context only.

Previous review (commit 012b6d2)

Status: 2 Issues Found | Recommendation: Address before merge

Executive Summary

The model_remains: null classification now matches the observed incident shape, but .nullish() also folds an omitted model_remains field into subscription_inactive, weakening the parse-failure signal this commit exists to preserve.

Overview

Severity Count
CRITICAL 0
WARNING 1
SUGGESTION 1
Issue Details (click to expand)

WARNING

File Line Issue
apps/web/src/lib/coding-plans/minimax-usage.ts 37 .nullish() accepts an omitted model_remains key, so that shape is logged as subscription_inactive instead of invalid_response.

SUGGESTION

File Line Issue
apps/web/src/lib/coding-plans/usage-contract.ts 54 subscription_inactive is only produced for active/past_due subscriptions, so the log label misdescribes the condition.
Files Reviewed (4 files)
  • apps/web/src/lib/coding-plans/minimax-usage.ts - 1 issue
  • apps/web/src/lib/coding-plans/minimax-usage.test.ts - 0 issues
  • apps/web/src/lib/coding-plans/usage-contract.ts - 1 issue
  • apps/web/src/routers/coding-plans-router.test.ts - 0 issues

Fix these issues in Kilo Cloud

Previous review (commit 9479953)

Status: 2 Issues Found | Recommendation: Address before merge

Executive Summary

The MiniMax quota hardening is directionally sound, but the new MiniMax-M* aggregate-row selection is broader than the documented wildcard marker and is not verified against the percent-less payload described in the PR body, so the fix may misreport quota or fail to resolve the incident.

Overview

Severity Count
CRITICAL 0
WARNING 2
SUGGESTION 0
Issue Details (click to expand)

WARNING

File Line Issue
apps/web/src/lib/coding-plans/minimax-usage.ts 95 /^minimax-m/i matches concrete per-model rows (e.g. MiniMax-M2), and the first match is treated as the account-wide aggregate with no ambiguity check.
apps/web/src/lib/coding-plans/minimax-usage.test.ts 113 Fixture supplies percent fields, but the PR body says the live MiniMax-M* capture has none; a percent-less row still yields empty windows and invalid_response.
Files Reviewed (3 files)
  • apps/web/src/lib/coding-plans/minimax-usage.ts - 1 issue
  • apps/web/src/lib/coding-plans/minimax-usage.test.ts - 1 issue
  • apps/web/src/routers/coding-plans-router.test.ts - 0 issues

Fix these issues in Kilo Cloud


Reviewed by deepseek-v4.1-flash · Input: 0 · Output: 0 · Cached: 0

Review guidance: REVIEW.md from base branch main

… plan

MiniMax returns HTTP 200 with `base_resp.status_code: 0` and
`model_remains: null` for a managed key whose Token Plan is not usable. The
response schema rejected `null`, so every lookup threw `invalid_response` and
`codingPlans.getUsage` returned 502.

Accept `null` and report the empty case with a distinct `subscription_inactive`
code, so support can separate a provider plan problem from a parse failure.

This supersedes the endpoint change in the previous commit. A live probe shows
both hosts return identical data, so the endpoint stays as it was.
@iscekic iscekic changed the title fix(coding-plans): harden MiniMax quota lookup fix(coding-plans): classify missing MiniMax quota rows as an inactive plan Sep 16, 2026
Comment thread apps/web/src/lib/coding-plans/minimax-usage.ts
Comment thread apps/web/src/lib/coding-plans/usage-contract.ts Outdated
@iscekic iscekic added the human-ready The PR is ready for human review. label Sep 16, 2026
An omitted `model_remains` key now maps to `invalid_response`. Only the
documented `null` and empty-array shapes report an inactive plan. A non-zero
application status without rows still maps to `application`.

Rename `subscription_inactive` to `provider_plan_inactive`. The adapter runs
only for active and past_due subscriptions, so the old label misdescribed the
condition in logs.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

human-ready The PR is ready for human review.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants