musistudio/claude-code-router · warning · Error
New API subscription response did not include quota fields.
Error message
New API subscription response did not include quota fields.
What it means
subscriptionQuotaMeter derives remaining/used/limit from the subscription response via several candidate JSON paths; if all three are undefined it cannot compute any quota and throws. This indicates the response shape does not match any known quota schema.
Source
Thrown at packages/electron/bundled-plugins/new-api-account/index.cjs:113
readPath(data, ["available_quota"]),
readPath(data, ["total_available"]),
readPath(data, ["balance"])
);
const used = firstNumber(
readPath(data, ["used_quota"]),
readPath(data, ["total_used"]),
readPath(data, ["used"])
);
const configuredLimit = firstNumber(
readPath(data, ["total_quota"]),
readPath(data, ["quota_total"]),
readPath(data, ["quota_limit"]),
readPath(data, ["total_granted"]),
readPath(data, ["limit"])
);
const limit = configuredLimit ?? (remaining !== undefined && used !== undefined ? remaining + used : undefined);
if (remaining === undefined && used === undefined && limit === undefined) {
throw new Error("New API subscription response did not include quota fields.");
}
return {
id: "new_api_subscription_quota",
kind: "quota",
label: readString(options.label) || "Subscription quota",
limit,
remaining,
resetAt: subscriptionResetAt(data),
unit: readString(options.unit) || "quota",
used
};
}
function subscriptionMessage(payload) {
const data = payloadData(payload);
return firstString(
readPath(data, ["plan_name"]),View on GitHub (pinned to 99f24806c6)
Solutions
- Log the subscription response and identify the actual quota field names
- Extend the readPath candidates (e.g. add ['data','quota_remaining']) to match the provider
- Configure options to point at the correct subscriptionPath returning quota data
- If the provider genuinely has no quota, skip quota metering for this account instead of throwing
Example fix
// before const remaining = firstDefined(readPath(data, ['remaining']), readPath(data, ['quota_remaining'])); // after const remaining = firstDefined( readPath(data, ['remaining']), readPath(data, ['quota_remaining']), readPath(data, ['data', 'remaining']) );
Defensive patterns
Strategy: fallback
Validate before calling
const hasQuota = remaining !== undefined || used !== undefined || limit !== undefined; const meter = hasQuota ? subscriptionQuotaMeter(data, options) : null; // skip metering instead of throwing
Type guard
null
Try / catch
catch (e) { if (/did not include quota fields/.test(e.message)) return null; throw e; } Prevention
- Keep readPath candidate list in sync with provider API docs
- Make quota metering optional per provider
- Snapshot real subscription payloads as fixtures
When it happens
Trigger: Provider returns a subscription payload without quota fields (free tier, different New API fork, changed field names like quota_remaining vs remaining), or response wrapped in an unexpected envelope so readPath misses.
Common situations: Switching provider forks (one-api/new-api variants), provider version upgrade renaming quota fields, or a stubbed test payload with only unrelated fields.
Understand the failure class
Background: Schema validation failed / invalid input schema: payload rejected because its shape doesn't match the expected schema — this error's family across 28 libraries.
Related errors
- New API refresh response did not include an access token.
- ${label} failed${payload.message ? `: ${String(payload.messa
AI-assisted analysis of musistudio/claude-code-router@99f24806c6 (2026-08-27).
Data as JSON: /api/errors/cfacb5cfe02a2bb6.
Report an issue: GitHub.