earendil-works/pi · error · Error
Invalid device code response
Error message
Invalid device code response
What it means
Error "Invalid device code response" thrown in earendil-works/pi.
Source
Thrown at packages/ai/src/auth/oauth/github-copilot.ts:223
async function startDeviceFlow(domain: string, signal: AbortSignal): Promise<DeviceCodeResponse> {
const urls = getUrls(domain);
const data = await fetchJson(urls.deviceCodeUrl, {
method: "POST",
headers: {
Accept: "application/json",
"Content-Type": "application/x-www-form-urlencoded",
"User-Agent": "GitHubCopilotChat/0.35.0",
},
body: new URLSearchParams({
client_id: CLIENT_ID,
scope: "read:user",
}),
signal,
});
if (!data || typeof data !== "object") {
throw new Error("Invalid device code response");
}
const deviceCode = (data as Record<string, unknown>).device_code;
const userCode = (data as Record<string, unknown>).user_code;
const verificationUri = (data as Record<string, unknown>).verification_uri;
const interval = (data as Record<string, unknown>).interval;
const expiresIn = (data as Record<string, unknown>).expires_in;
if (
typeof deviceCode !== "string" ||
typeof userCode !== "string" ||
typeof verificationUri !== "string" ||
(interval !== undefined && typeof interval !== "number") ||
typeof expiresIn !== "number"
) {
throw new Error("Invalid device code response fields");
}
View on GitHub (pinned to 4af9d21d3b)
Solutions
- Retry the device code request; validate the response shape before use.
When it happens
Trigger: Thrown at packages/ai/src/auth/oauth/github-copilot.ts:223 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of earendil-works/pi@4af9d21d3b (2026-08-24).
Data as JSON: /api/errors/647c20421bf5dc26.
Report an issue: GitHub.