diegosouzapw/OmniRoute · error · CodexDeviceFlowError

network

network

Error message

Failed to reach OpenAI: ${e?.message || e}

What it means

Error "Failed to reach OpenAI: ${e?.message || e}" thrown in diegosouzapw/OmniRoute.

Source

Thrown at src/lib/oauth/codexDeviceFlow.ts:146

/**
 * Step 1 — request a one-time user code + device_auth_id.
 * A 404 here means device code login is disabled for this account/workspace.
 */
export async function requestUserCode(
  clientId: string = DEFAULT_CLIENT_ID,
  signal?: AbortSignal
): Promise<CodexUserCode> {
  let res: Response;
  try {
    res = await fetch(`${API_BASE_URL}/deviceauth/usercode`, {
      method: "POST",
      headers: { "Content-Type": "application/json", Accept: "application/json" },
      body: JSON.stringify({ client_id: clientId }),
      signal,
    });
  } catch (e: any) {
    if (e?.name === "AbortError") throw new CodexDeviceFlowError("aborted", "Device flow aborted");
    throw new CodexDeviceFlowError("network", `Failed to reach OpenAI: ${e?.message || e}`);
  }

  if (res.status === 404) {
    throw new CodexDeviceFlowError(
      "device_disabled",
      "Device code login is not enabled for this account. Enable it in ChatGPT security settings (or ask your workspace admin), or use the localhost 'Adicionar' flow.",
      404
    );
  }

  if (!res.ok) {
    const text = await res.text().catch(() => "");
    throw new CodexDeviceFlowError(
      "usercode_failed",
      `Failed to request device code (${res.status}): ${text}`,
      res.status
    );
  }

View on GitHub (pinned to a179ffed5b)

When it happens

Trigger: Thrown at src/lib/oauth/codexDeviceFlow.ts:146 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/c1e7466f7a439eae. Report an issue: GitHub.