{"record":{"id":"64d5466febb3cd9c","repo":"diegosouzapw/OmniRoute","slug":"grok-returned-an-invalid-verification-url","errorCode":null,"errorMessage":"Grok returned an invalid verification URL","messagePattern":"Grok returned an invalid verification URL","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/lib/oauth/providers/grok-cli.ts","lineNumber":73,"sourceCode":"  try {\n    const value = await response.json();\n    return value && typeof value === \"object\" ? (value as Record<string, unknown>) : {};\n  } catch {\n    return {\n      error: \"invalid_response\",\n      error_description: \"xAI returned a non-JSON OAuth response\",\n    };\n  }\n}\n\nfunction validateVerificationUri(value: string): void {\n  if (\n    [...value].some((character) => {\n      const codePoint = character.codePointAt(0) ?? 0;\n      return codePoint <= 0x1f || codePoint === 0x7f;\n    })\n  ) {\n    throw new Error(\"Grok returned an invalid verification URL\");\n  }\n\n  let url: URL;\n  try {\n    url = new URL(value);\n  } catch {\n    throw new Error(\"Grok returned an invalid verification URL\");\n  }\n\n  const isLocalHttp =\n    url.protocol === \"http:\" && (url.hostname === \"localhost\" || url.hostname === \"127.0.0.1\");\n  if (url.protocol !== \"https:\" && !isLocalHttp) {\n    throw new Error(\"Grok returned an unsupported verification URL\");\n  }\n}\n\n/**\n * Device-code flow (#7358). Kept alongside the browser PKCE flow below (#7013","sourceCodeStart":55,"sourceCodeEnd":91,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/oauth/providers/grok-cli.ts#L55-L91","documentation":"validateVerificationUri found control characters in xAI's verification_uri, or the value is not parseable as a URL — the upstream response is malformed/untrusted and is refused rather than shown to the user.","triggerScenarios":"Thrown at src/lib/oauth/providers/grok-cli.ts:73 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Retry the device-code request — likely a corrupted upstream response","Report the malformed response; do not bypass the validation"],"exampleFix":null,"handlingStrategy":"fallback","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"}