diegosouzapw/OmniRoute · error

Device code request failed

Error message

Device code request failed: ${error}

What it means

Non-429 error path in kimi-coding's requestDeviceCode: the POST to deviceCodeUrl returned a non-ok status. The raw upstream response text is interpolated into the message. Signals the Kimi OAuth device-code endpoint rejected the request (bad client_id, server error, or outage).

Solutions

  1. Inspect the interpolated error body for the upstream reason (e.g. invalid_client, server error)
  2. Confirm config.clientId matches a valid Kimi Coding OAuth client
  3. Retry with backoff on 5xx upstream errors
  4. Sanitize the upstream text before exposing the message in API responses
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at src/lib/oauth/providers/kimi-coding.ts:72 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/dbd276a9f12181a5. Report an issue: GitHub.

Appendix: source

Thrown at src/lib/oauth/providers/kimi-coding.ts:72

    }),
  };
}

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) => {

View on GitHub (pinned to a179ffed5b)