coleam00/Archon · error · DeviceFlowError
${data.error}
Error message
${data.error} What it means
startDeviceFlow requests a device and user code from GitHub's OAuth device-flow endpoint. When GitHub responds with an `error` field (e.g. invalid client_id), the library throws DeviceFlowError carrying that exact error code so the caller can surface the OAuth failure verbatim.
Source
Thrown at packages/core/src/github-auth/device-flow.ts:90
const body = (await res.json()) as { error_description?: string; error?: string };
detail = body.error_description ?? body.error ?? '';
} catch {
// Body was not JSON — fall back to the status line only.
}
throw new DeviceFlowError(
'http_error',
`GitHub device flow returned HTTP ${res.status}${detail ? `: ${detail}` : ''}`
);
}
return (await res.json()) as T;
}
/** Step 1: request device + user codes. */
export async function startDeviceFlow(clientId: string): Promise<DeviceCodeResponse> {
const data = await postForm<DeviceCodeResponse & { error?: string }>(DEVICE_CODE_URL, {
client_id: clientId,
});
if (data.error) throw new DeviceFlowError(data.error);
return data;
}
export interface PollOptions {
signal?: AbortSignal;
/** Injectable sleep for deterministic tests. */
sleep?: (ms: number) => Promise<void>;
}
const defaultSleep = (ms: number): Promise<void> => new Promise(resolve => setTimeout(resolve, ms));
/**
* Step 2: poll until the user authorizes. Handles `authorization_pending`
* (keep waiting) and `slow_down` (back off using the server-supplied interval).
* Any other `error` is terminal and thrown as a DeviceFlowError.
*/
export async function pollDeviceFlow(
clientId: string,View on GitHub (pinned to 0773b97458)
Solutions
- Verify GITHUB_CLIENT_ID matches the OAuth App / GitHub App client ID in developer settings
- Catch DeviceFlowError and print its code against GitHub's device-flow error docs (e.g. incorrect_client_id)
- Re-create the OAuth app if it was deleted or suspended
- Retry later if GitHub is having an incident
Example fix
// before
await startDeviceFlow(process.env.MY_APP_ID!);
// after
const clientId = process.env.GITHUB_CLIENT_ID;
if (!clientId) throw new Error('GITHUB_CLIENT_ID not set');
await startDeviceFlow(clientId); Defensive patterns
Strategy: try-catch
Validate before calling
if (!clientId || !/^[A-Za-z0-9]+$/.test(clientId)) throw new Error('Invalid GITHUB_CLIENT_ID before starting device flow'); Try / catch
try { const dc = await startDeviceFlow(clientId); } catch (e) { if (e instanceof DeviceFlowError) { console.error(`GitHub device code request failed: ${e.code}`); } throw e; } Prevention
- Validate the client ID is present and non-empty before calling
- Store the client ID in one config location and verify it against the GitHub app settings after changes
When it happens
Trigger: Calling startDeviceFlow(clientId) when the GitHub token POST to DEVICE_CODE_URL returns a JSON body with an `error` property (device code endpoint rejects the request).
Common situations: Misconfigured or revoked OAuth App client ID; client ID copied from the wrong app; GitHub outages returning error payloads; network proxies injecting error responses.
Related errors
- ${result.code}
- Authentication failed for ${owner}/${repo}. ${authHint}
- aborted
- Copilot authentication failed: ${combined} Run `copilot log
- Repository ${owner}/${repo} not found or is private. Check r
AI-assisted analysis of coleam00/Archon@0773b97458 (2026-09-01).
Data as JSON: /api/errors/1a06045a871ec280.
Report an issue: GitHub.