{"record":{"id":"d02018101a7e0209","repo":"diegosouzapw/OmniRoute","slug":"device-authorization-response-missing-device-code","errorCode":null,"errorMessage":"Device authorization response missing device_code","messagePattern":"Device authorization response missing device_code","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/lib/oauth/providers/kimi-coding.ts","lineNumber":76,"sourceCode":"export const kimiCoding = {\n  config: KIMI_CODING_CONFIG,\n  flowType: \"device_code\",\n  requestDeviceCode: async (config) => {\n    const response = await fetch(config.deviceCodeUrl, {\n      method: \"POST\",\n      headers: getKimiOAuthHeaders(),\n      body: new URLSearchParams({\n        client_id: config.clientId,\n      }),\n    });\n\n    if (!response.ok) {\n      const error = await response.text();\n      throw new Error(`Device code request failed: ${error}`);\n    }\n\n    const data = await response.json();\n    if (!data?.device_code) throw new Error(\"Device authorization response missing device_code\");\n    if (!data?.user_code) throw new Error(\"Device authorization response missing user_code\");\n    if (!data?.verification_uri_complete) {\n      throw new Error(\"Device authorization response missing verification_uri_complete\");\n    }\n    return {\n      device_code: data.device_code,\n      user_code: data.user_code,\n      verification_uri: data.verification_uri || \"\",\n      verification_uri_complete: data.verification_uri_complete,\n      expires_in: data.expires_in,\n      interval: data.interval || 5,\n    };\n  },\n  pollToken: async (config, deviceCode) => {\n    const response = await fetch(config.tokenUrl, {\n      method: \"POST\",\n      headers: getKimiOAuthHeaders(),\n      body: new URLSearchParams({","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/oauth/providers/kimi-coding.ts#L58-L94","documentation":"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.","triggerScenarios":"Thrown at src/lib/oauth/providers/kimi-coding.ts:76 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}