diegosouzapw/OmniRoute · error
Device authorization response missing device_code
Error message
Device authorization response missing device_code
What it means
The device-authorization POST succeeded (2xx) and the body parsed as JSON, but data.device_code is missing. The Kimi device-flow endpoint answered with an unexpected schema (error payload, maintenance page, or API change), so there is no device_code to poll with and the flow cannot continue.
Solutions
- Retry requestDeviceCode after a backoff — transient schema-oddity/error bodies from the device endpoint often clear
- Verify the clientId sent in the POST body is still the correct public client id for the Kimi OAuth endpoint
- Log (sanitized) the full response body to identify whether it is an error payload or an API contract change
- If the endpoint contract changed, update requestDeviceCode to read the new device_code field mapping
Defensive patterns
Strategy: retry
When it happens
Trigger: Thrown at src/lib/oauth/providers/kimi-coding.ts:76 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/d02018101a7e0209.
Report an issue: GitHub.
Appendix: source
Thrown at src/lib/oauth/providers/kimi-coding.ts:76
export const kimiCoding = {
config: KIMI_CODING_CONFIG,
flowType: "device_code",
requestDeviceCode: async (config) => {
const response = await fetch(config.deviceCodeUrl, {
method: "POST",
headers: getKimiOAuthHeaders(),
body: new URLSearchParams({
client_id: config.clientId,
}),
});
if (!response.ok) {
const error = await response.text();
throw new Error(`Device code request failed: ${error}`);
}
const data = await response.json();
if (!data?.device_code) throw new Error("Device authorization response missing device_code");
if (!data?.user_code) throw new Error("Device authorization response missing user_code");
if (!data?.verification_uri_complete) {
throw new Error("Device authorization response missing verification_uri_complete");
}
return {
device_code: data.device_code,
user_code: data.user_code,
verification_uri: data.verification_uri || "",
verification_uri_complete: data.verification_uri_complete,
expires_in: data.expires_in,
interval: data.interval || 5,
};
},
pollToken: async (config, deviceCode) => {
const response = await fetch(config.tokenUrl, {
method: "POST",
headers: getKimiOAuthHeaders(),
body: new URLSearchParams({View on GitHub (pinned to a179ffed5b)