musistudio/claude-code-router · error · Error
${label} failed${payload.message ? `: ${String(payload.messa
Error message
${label} failed${payload.message ? `: ${String(payload.message)}` : ""}. What it means
assertSuccessfulPayload inspects provider JSON payloads for success === false or code === false and converts them into an Error labeled with the operation (e.g. 'New API refresh'). The provider's message field is appended verbatim, so the underlying cause text comes from the remote API.
Source
Thrown at packages/electron/bundled-plugins/new-api-account/index.cjs:191
return undefined;
}
if (typeof value === "number") {
if (value <= 0) {
return undefined;
}
const date = new Date(value > 100000000000 ? value : value * 1000);
return Number.isNaN(date.getTime()) ? undefined : date.toISOString();
}
const date = new Date(value);
return Number.isNaN(date.getTime()) ? undefined : date.toISOString();
}
function assertSuccessfulPayload(payload, label) {
if (!isRecord(payload)) {
return;
}
if (payload.success === false || payload.code === false) {
throw new Error(`${label} failed${payload.message ? `: ${String(payload.message)}` : ""}.`);
}
}
function payloadData(payload) {
return isRecord(payload) && isRecord(payload.data) ? payload.data : payload;
}
function providerBaseUrl(provider) {
return readString(provider?.api_base_url) || readString(provider?.baseUrl) || readString(provider?.baseurl);
}
function newApiRootBaseUrl(baseUrl) {
const value = readString(baseUrl);
if (!value) {
return "";
}
try {
const url = new URL(providerUrlWithDefaultScheme(value));View on GitHub (pinned to 99f24806c6)
Solutions
- Read the appended provider message — it states the remote failure reason
- Fix the root cause (credentials, quota, endpoint) identified by that message
- If the provider uses a different failure flag (numeric code), extend assertSuccessfulPayload to interpret it
- Retry only for transient messages like rate limiting, with backoff
Example fix
// before
if (payload.success === false || payload.code === false) { throw new Error(`${label} failed...`); }
// after
if (payload.success === false || payload.code === false || Number(payload.code) > 0) {
throw new Error(`${label} failed: ${String(payload.message ?? payload.code)}.`);
} Defensive patterns
Strategy: try-catch
Validate before calling
null
Type guard
null
Try / catch
try { await call(); } catch (e) {
if (e instanceof Error && /failed(?! to)/.test(e.message)) {
const reason = e.message.split(': ')[1] ?? 'provider error';
handleProviderReason(reason);
} else throw e;
} Prevention
- Surface the embedded provider message to users verbatim
- Distinguish auth vs quota vs rate-limit reasons for retry policy
- Don't retry non-idempotent calls on soft failures
When it happens
Trigger: Any New API HTTP call whose body is { success: false, message: '...' } (or code: false) — invalid credentials, insufficient quota, rate limit, bad endpoint — after fetch itself resolved successfully.
Common situations: Wrong API key, expired token, quota exhausted, provider returning soft errors with HTTP 200, or message in a non-English locale/HTML content.
Related errors
- New API refresh response did not include an access token.
- New API subscription response did not include quota fields.
AI-assisted analysis of musistudio/claude-code-router@99f24806c6 (2026-08-27).
Data as JSON: /api/errors/48fe9780dc41eb02.
Report an issue: GitHub.