decolua/9router · error · Error
`CodeBuddy Intl state request failed: ${await response.text(
Error message
`CodeBuddy Intl state request failed: ${await response.text()}` What it means
CodeBuddy International device-flow bootstrap: the POST requesting device 'state' returned a non-2xx HTTP status, and the raw body text is thrown inside this Error. Same mechanism as the CN variant [201] but against the intl endpoint; it aborts the device flow before polling begins.
Source
Thrown at src/lib/oauth/providers/codebuddy-intl.js:22
const codebuddyIntl = {
config: CODEBUDDY_INTL_CONFIG,
flowType: "device_code",
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,View on GitHub (pinned to 90b52e06ff)
Solutions
- Check the thrown body text for HTTP status clues (404 vs 403 vs 5xx).
- Verify reachability of the CodeBuddy Intl base URL from this machine (curl / browser).
- Ensure the proxy allows the X-No-Authorization / X-No-User-Id / X-Product headers through.
- Update the provider's stateUrl if the intl API was relocated.
Example fix
// before
if (!response.ok) throw new Error(`CodeBuddy Intl state request failed: ${await response.text()}`);
// after
if (!response.ok) {
const t = await response.text();
throw new Error(`CodeBuddy Intl state request failed (HTTP ${response.status}): ${t.slice(0, 500)}`);
} Defensive patterns
Strategy: retry
Validate before calling
// Precheck intl endpoint reachability
const reachable = await fetch(config.stateUrl, { method: "OPTIONS" })
.then(r => r.status < 500).catch(() => false);
if (!reachable) throw new Error("CodeBuddy Intl state endpoint unreachable"); Type guard
function hasValidDeviceState(data) {
return !!data && typeof data === "object" &&
data.code === 0 && typeof data.data?.state === "string" &&
typeof data.data?.authUrl === "string";
} Try / catch
try {
const s = await startCodeBuddyIntlFlow();
} catch (err) {
if (String(err.message).includes("CodeBuddy Intl state request failed")) {
await retryWithBackoff(() => startCodeBuddyIntlFlow(), { retries: 3, baseMs: 1000 });
} else throw err;
} Prevention
- Verify outbound access to the Intl endpoint (geo/proxy) before shipping the flow.
- Ensure custom X-* headers survive your proxy (some strip unknown headers).
- Use exponential backoff on non-2xx instead of immediate hard failure.
- Keep the intl base URL configurable so endpoint migrations need no code change.
When it happens
Trigger: Calling the codebuddy-intl startDeviceFlow when its state endpoint responds !response.ok — endpoint outage, 404 after an API change, proxy/firewall block, or rejection of the anonymous SaaS headers with body '{}'.
Common situations: Intl endpoint temporarily down or geo-restricted; corporate proxy stripping custom X-* headers; stale base URL after a provider-side migration; DNS/TLS failure surfacing as a gateway error page.
Related errors
- `CodeBuddy state request failed: ${await response.text()}`
- `ClinePass token exchange failed: ${error}`
- `Device code request failed: ${error}`
- `Grok CLI device code request failed: ${error}`
- `Device auth initiation failed: ${error}`
AI-assisted analysis of decolua/9router@90b52e06ff (2026-08-30).
Data as JSON: /api/errors/df409b20b2962cf9.
Report an issue: GitHub.