decolua/9router · error · Error
`CodeBuddy Intl state error: ${data.msg || "missing state/au
Error message
`CodeBuddy Intl state error: ${data.msg || "missing state/authUrl"}` What it means
CodeBuddy International returned HTTP 200 but the application envelope is an error: code !== 0 or data.data.state / data.data.authUrl is absent. The API's msg is embedded in the message, defaulting to 'missing state/authUrl'. This is a payload-level rejection, distinct from the transport-level [203].
Source
Thrown at src/lib/oauth/providers/codebuddy-intl.js:25
requestDeviceCode: async (config) => {
const response = await fetch(`${config.stateUrl}?platform=${config.platform}`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Accept: "application/json",
"User-Agent": config.userAgent,
"X-Requested-With": "XMLHttpRequest",
"X-Domain": "www.codebuddy.ai",
"X-No-Authorization": "true",
"X-No-User-Id": "true",
"X-Product": "SaaS",
},
body: "{}",
});
if (!response.ok) throw new Error(`CodeBuddy Intl state request failed: ${await response.text()}`);
const data = await response.json();
if (data.code !== 0 || !data.data?.state || !data.data?.authUrl) {
throw new Error(`CodeBuddy Intl state error: ${data.msg || "missing state/authUrl"}`);
}
return {
device_code: data.data.state,
verification_uri: data.data.authUrl,
user_code: "",
interval: config.pollInterval / 1000,
_isCodeBuddy: true,
};
},
pollToken: async (config, deviceCode) => {
const response = await fetch(`${config.tokenUrl}?state=${encodeURIComponent(deviceCode)}`, {
method: "GET",
headers: {
Accept: "application/json",
"User-Agent": config.userAgent,
"X-Requested-With": "XMLHttpRequest",
"X-Domain": "www.codebuddy.ai",
"X-No-Authorization": "true",View on GitHub (pinned to 90b52e06ff)
Solutions
- Read the msg in the message for the API's stated reason.
- Dump the full JSON envelope and verify expected keys {code, data:{state, authUrl}}; adjust field access if the schema moved.
- Retry the request — application errors here are often transient.
- Check for CodeBuddy Intl client updates and sync the provider config.
Example fix
// before
if (data.code !== 0 || !data.data?.state || !data.data?.authUrl) {
throw new Error(`CodeBuddy Intl state error: ${data.msg || "missing state/authUrl"}`);
}
// after
if (data.code !== 0 || !data.data?.state || !data.data?.authUrl) {
throw new Error(`CodeBuddy Intl state error: ${data.msg || "missing state/authUrl"} (code=${data.code}, keys=${Object.keys(data.data || {})})`);
} Defensive patterns
Strategy: validation
Validate before calling
// Validate intl envelope before use
const data = await response.json();
if (data.code !== 0 || !data.data?.state || !data.data?.authUrl) {
console.error("CodeBuddy Intl envelope:", JSON.stringify(data).slice(0, 1000));
} Type guard
function isCodeBuddyIntlStateEnvelope(v) {
return !!v && typeof v === "object" && v.code === 0 &&
typeof v.data === "object" && v.data !== null &&
typeof v.data.state === "string" && v.data.state.length > 0 &&
typeof v.data.authUrl === "string" && /^https?:\/\//.test(v.data.authUrl);
} Try / catch
try {
const s = await startCodeBuddyIntlFlow();
} catch (err) {
if (String(err.message).includes("CodeBuddy Intl state error")) {
console.error("CodeBuddy Intl API rejection:", err.message);
// inspect msg; retry only if it indicates a transient condition
} else throw err;
} Prevention
- Capture and store the full envelope on failure to diagnose schema drift.
- Gate retries on the msg/code value — some rejections are permanent.
- Version-pin the provider config against the intl API you tested against.
- Validate URL shape of authUrl before handing it to a browser/opener.
When it happens
Trigger: The intl state endpoint responds 200 with { code: non-zero } or a reshaped payload missing state/authUrl — service degradation returning 200, schema drift in the intl API, or region/policy restrictions reported via msg.
Common situations: Intl API response shape changed in an update; temporary server-side condition like 'login busy' or maintenance encoded as code!=0; account restrictions; CDN/edge serving a 200 stub.
Related errors
- `CodeBuddy state error: ${data.msg || "missing state/authUrl
- `CodeBuddy state request failed: ${await response.text()}`
- `CodeBuddy Intl state request failed: ${await response.text(
- `Device code request failed: ${error}`
- `Grok CLI device code request failed: ${error}`
AI-assisted analysis of decolua/9router@90b52e06ff (2026-08-30).
Data as JSON: /api/errors/869128f31937c150.
Report an issue: GitHub.