diegosouzapw/OmniRoute · error

Grok device authorization response is incomplete

Error message

Grok device authorization response is incomplete

What it means

Thrown by requestDeviceCode after parseOAuthResponse succeeded and response.ok was true, but the JSON body lacked a string device_code, user_code, or verification_uri. It means Grok's device-authorization endpoint returned 2XX with a malformed/partial payload — an upstream contract violation, not a user input problem.

Solutions

  1. Verify Grok's device authorization endpoint is not returning an HTML error page or partial JSON with a 200 status
  2. Check for Grok API changes to the device authorization response schema (field renames, nesting)
  3. Capture and inspect the raw response body to confirm which of device_code/user_code/verification_uri is absent or non-string
  4. Retry the device code request — transient gateway truncation can produce incomplete bodies
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at src/lib/oauth/providers/grok-cli.ts:130 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/1a0bc571114d6ad7. Report an issue: GitHub.

Appendix: source

Thrown at src/lib/oauth/providers/grok-cli.ts:130

      scope: config.scope,
      referrer: GROK_BUILD_OAUTH_REFERRER,
    }),
  });
  const data = await parseOAuthResponse(response);

  if (!response.ok) {
    throw new Error(
      typeof data.error_description === "string"
        ? data.error_description
        : "Grok device authorization failed"
    );
  }
  if (
    typeof data.device_code !== "string" ||
    typeof data.user_code !== "string" ||
    typeof data.verification_uri !== "string"
  ) {
    throw new Error("Grok device authorization response is incomplete");
  }
  if (!/^[A-Za-z0-9-]+$/.test(data.user_code)) {
    throw new Error("Grok returned an invalid device code");
  }
  validateVerificationUri(data.verification_uri);
  if (typeof data.verification_uri_complete === "string") {
    validateVerificationUri(data.verification_uri_complete);
  }

  return {
    device_code: data.device_code,
    user_code: data.user_code,
    verification_uri: data.verification_uri,
    verification_uri_complete:
      typeof data.verification_uri_complete === "string"
        ? data.verification_uri_complete
        : data.verification_uri,
    expires_in: typeof data.expires_in === "number" ? data.expires_in : 1800,

View on GitHub (pinned to a179ffed5b)