{"record":{"id":"5f1a115bf0d91488","repo":"musistudio/claude-code-router","slug":"grok-cli-oidc-discovery-returned-http-response-s","errorCode":null,"errorMessage":"Grok CLI OIDC discovery returned HTTP ${response.status}${tokenRefreshErrorMessage(payload, text)}","messagePattern":"Grok CLI OIDC discovery returned HTTP (.+?)(.+?)","errorType":"http","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/core/src/agents/local-providers/grok.ts","lineNumber":749,"sourceCode":"async function grokTokenEndpoint(auth: GrokTokenSet): Promise<string> {\n  const configured = readString(process.env.GROK_OIDC_TOKEN_ENDPOINT);\n  if (configured) {\n    return configured;\n  }\n  const issuer = (auth.oidcIssuer || readString(process.env.GROK_OIDC_ISSUER) || grokDefaultOidcIssuer).replace(/\\/+$/, \"\");\n  const metadataUrl = `${issuer}/.well-known/openid-configuration`;\n  const timeoutMs = normalizeGrokOauthTimeout(process.env.GROK_OIDC_REFRESH_TIMEOUT_MS);\n  const controller = new AbortController();\n  const timer = setTimeout(() => controller.abort(), timeoutMs);\n  try {\n    const response = await fetchWithSystemProxy(metadataUrl, {\n      headers: { accept: \"application/json\" },\n      signal: controller.signal\n    });\n    const text = await response.text();\n    const payload = parseJsonRecord(text);\n    if (!response.ok) {\n      throw new Error(`Grok CLI OIDC discovery returned HTTP ${response.status}${tokenRefreshErrorMessage(payload, text)}`);\n    }\n    const tokenEndpoint = readString(payload?.token_endpoint) || readString(payload?.tokenEndpoint);\n    if (!tokenEndpoint) {\n      throw new Error(\"Grok CLI OIDC discovery did not return a token endpoint.\");\n    }\n    return tokenEndpoint;\n  } catch (error) {\n    if (error instanceof Error && error.name === \"AbortError\") {\n      throw new Error(`Grok CLI OIDC discovery timed out after ${timeoutMs}ms.`);\n    }\n    throw error;\n  } finally {\n    clearTimeout(timer);\n  }\n}\n\nfunction grokCredentialFiles(): string[] {\n  const explicitFile = process.env.GROK_AUTH_FILE?.trim();","sourceCodeStart":731,"sourceCodeEnd":767,"githubUrl":"https://github.com/musistudio/claude-code-router/blob/99f24806c6a2c660b16e53e95211c517448a6c90/packages/core/src/agents/local-providers/grok.ts#L731-L767","documentation":"During Grok OIDC discovery, the well-known configuration endpoint returned a non-2xx status. The message includes the status code and any parseable error detail, thrown before a token endpoint can be resolved for the refresh flow.","triggerScenarios":"fetching the OIDC discovery/well-known URL returns !response.ok — wrong/rotated discovery URL, 404 from a host that no longer serves discovery, or a 5xx during provider outage.","commonSituations":"The provider changed its OIDC issuer/host and cached configuration points to the old URL; regional endpoints differ; a proxy returns 407/502 for the discovery host.","solutions":["Re-run login to refresh the cached discovery/issuer URL","curl the discovery URL to confirm what status the host returns","Check for proxy/VPN interference on the discovery host","Retry — 5xx discovery failures are often transient"],"exampleFix":null,"handlingStrategy":"retry","validationCode":"const discoveryOk = await fetch(discoveryUrl, { method: 'HEAD' }).then(r => r.ok).catch(() => false);\nif (!discoveryOk) deferProviderImport();","typeGuard":null,"tryCatchPattern":"catch (e) {\n  if (e instanceof Error && e.message.startsWith('Grok CLI OIDC discovery returned HTTP')) {\n    const status = Number(e.message.match(/HTTP (\\d+)/)?.[1]);\n    if (status >= 500 || status === 429) await retryWithBackoff();\n    else await refreshDiscoveryConfig();\n  }\n}","preventionTips":["Cache the discovered token endpoint so discovery is not re-run every refresh","Treat discovery 4xx as configuration drift, not transient failure"],"tags":["oidc","discovery","grok","http-status","oauth"],"backgroundTag":"oidc-discovery-failed","analyzedSha":"99f24806c6a2c660b16e53e95211c517448a6c90","analyzedAt":"2026-08-27T04:11:01.184Z","schemaVersion":2},"datasetVersion":"2026-08-27T08:17:20.692Z"}