{"record":{"id":"5cac0bf28b9a9edc","repo":"coleam00/Archon","slug":"http-error","errorCode":"http_error","errorMessage":"GitHub device flow returned HTTP ${res.status}${detail ? `: ${detail}` : ''}","messagePattern":"GitHub device flow returned HTTP (.+?)(.+?)` : ''\\}","errorType":"error_code","errorClass":"DeviceFlowError","httpStatus":null,"severity":"error","filePath":"packages/core/src/github-auth/device-flow.ts","lineNumber":77,"sourceCode":"\nasync function postForm<T>(url: string, params: Record<string, string>): Promise<T> {\n  const res = await fetch(url, {\n    method: 'POST',\n    headers: { Accept: 'application/json', 'Content-Type': 'application/x-www-form-urlencoded' },\n    body: new URLSearchParams(params).toString(),\n  });\n  if (!res.ok) {\n    // GitHub returns actionable detail in the body even on non-2xx (e.g.\n    // {\"error\":\"invalid_client\",\"error_description\":\"...\"}). Surface it so a\n    // misconfigured client id reads as more than a bare \"HTTP 401\".\n    let detail = '';\n    try {\n      const body = (await res.json()) as { error_description?: string; error?: string };\n      detail = body.error_description ?? body.error ?? '';\n    } catch {\n      // Body was not JSON — fall back to the status line only.\n    }\n    throw new DeviceFlowError(\n      'http_error',\n      `GitHub device flow returned HTTP ${res.status}${detail ? `: ${detail}` : ''}`\n    );\n  }\n  return (await res.json()) as T;\n}\n\n/** Step 1: request device + user codes. */\nexport async function startDeviceFlow(clientId: string): Promise<DeviceCodeResponse> {\n  const data = await postForm<DeviceCodeResponse & { error?: string }>(DEVICE_CODE_URL, {\n    client_id: clientId,\n  });\n  if (data.error) throw new DeviceFlowError(data.error);\n  return data;\n}\n\nexport interface PollOptions {\n  signal?: AbortSignal;","sourceCodeStart":59,"sourceCodeEnd":95,"githubUrl":"https://github.com/coleam00/Archon/blob/0773b9745896ef0612e709c80845a0f7db315b19/packages/core/src/github-auth/device-flow.ts#L59-L95","documentation":"Error \"GitHub device flow returned HTTP ${res.status}${detail ? `: ${detail}` : ''}\" thrown in coleam00/Archon.","triggerScenarios":"Thrown at packages/core/src/github-auth/device-flow.ts:77 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"0773b9745896ef0612e709c80845a0f7db315b19","analyzedAt":"2026-09-01T02:28:07.064Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T05:18:18.240Z"}