diegosouzapw/OmniRoute · error
CodeBuddy state error
Error message
CodeBuddy state error: ${json.msg || "no state in response"} What it means
CodeBuddy CN flow: the state endpoint answered 2xx but the JSON body's code field is not the success value (or data is missing) — the application-level error whose msg (or 'no state in response') is surfaced.
Solutions
- Read json.msg for the Tencent-side reason (rate limit, invalid platform)
- Retry after backoff for transient app-level errors
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at src/lib/oauth/providers/codebuddy-cn.ts:66 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25).
Data as JSON: /api/errors/0db2bfcb1adc357c.
Report an issue: GitHub.
Appendix: source
Thrown at src/lib/oauth/providers/codebuddy-cn.ts:66
Accept: "application/json",
"User-Agent": config.userAgent,
"X-Requested-With": "XMLHttpRequest",
"X-Domain": "copilot.tencent.com",
"X-No-Authorization": "true",
"X-No-User-Id": "true",
"X-Product": "SaaS",
},
body: JSON.stringify({ platform: config.platform }),
});
if (!response.ok) {
const err = await response.text();
throw new Error(`CodeBuddy state request failed (${response.status})`);
}
const json = (await response.json()) as { code?: number; data?: any; msg?: string };
if (json.code !== 0 || !json.data?.state) {
throw new Error(`CodeBuddy state error: ${json.msg || "no state in response"}`);
}
const state = String(json.data.state);
const authUrl = String(json.data.authUrl || json.data.url || "");
return {
device_code: state,
user_code: state,
verification_uri: authUrl,
verification_uri_complete: authUrl,
expires_in: 600,
interval: Math.max(1, Math.floor((config.pollInterval || 5000) / 1000)),
};
},
pollToken: async (config: CodeBuddyConfig, deviceCode: string): Promise<CodeBuddyPollResult> => {
// GET with state as a query param (not POST/body) — matches the official CLI's
// /v2/plugin/auth/token?state=... endpoint shape.
const response = await fetch(View on GitHub (pinned to a179ffed5b)