{"record":{"id":"89f971be8a6f1fe6","repo":"jackwener/OpenCLI","slug":"http-result-httpstatus-from-api-v1-auths","errorCode":null,"errorMessage":"HTTP ${result.httpStatus} from /api/v1/auths/","messagePattern":"HTTP (.+?) from /api/v1/auths/","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/qwen/auth.js","lineNumber":37,"sourceCode":"  const result = await page.evaluate(`(async () => {\n    try {\n      const token = ${JSON.stringify(token)};\n      const res = await fetch('/api/v1/auths/', { credentials: 'include', headers: { 'Authorization': 'Bearer ' + token, 'Accept': 'application/json' } });\n      if (res.status === 401 || res.status === 403) {\n        return { kind: 'auth', detail: 'Qwen /api/v1/auths/ HTTP ' + res.status };\n      }\n      if (!res.ok) return { kind: 'http', httpStatus: res.status };\n      const d = await res.json();\n      if (!d || !d.id) {\n        return { kind: 'auth', detail: 'Qwen /api/v1/auths/ returned no user id' };\n      }\n      return { ok: true, user_id: String(d.id), name: String(d.name || '') };\n    } catch (e) {\n      return { kind: 'exception', detail: String(e && e.message || e) };\n    }\n  })()`);\n  if (result?.kind === 'auth') throw new AuthRequiredError('qwen.ai', result.detail);\n  if (result?.kind === 'http') throw new CommandExecutionError(`HTTP ${result.httpStatus} from /api/v1/auths/`);\n  if (result?.kind === 'exception') throw new CommandExecutionError(`Qwen whoami failed: ${result.detail}`);\n  if (!result?.ok) throw new CommandExecutionError(`Unexpected Qwen probe: ${JSON.stringify(result)}`);\n  return { user_id: result.user_id, name: result.name };\n}\n\nregisterSiteAuthCommands({\n  site: 'qwen',\n  domain: 'qwen.ai',\n  loginUrl: 'https://chat.qwen.ai/auth?action=login',\n  columns: ['user_id', 'name'],\n  quickCheck: hasQwenSessionCookie,\n  verify: verifyQwenIdentity,\n  poll: async (page) => {\n    if (!await hasQwenSessionCookie(page)) {\n      throw new AuthRequiredError('qwen.ai', 'Waiting for Qwen token cookie');\n    }\n    return verifyQwenIdentity(page);\n  },","sourceCodeStart":19,"sourceCodeEnd":55,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/qwen/auth.js#L19-L55","documentation":"CommandExecutionError thrown by verifyQwenIdentity when the whoami probe reports kind:'http' — the /api/v1/auths/ endpoint answered with a non-auth, unexpected HTTP status (result.httpStatus interpolated into the message). The token was accepted far enough not to be 'auth' but the API call itself failed.","triggerScenarios":"Server returns 5xx, 429 (rate limit), 404 (endpoint moved), or a proxy/CDN error page during the whoami fetch inside page.evaluate.","commonSituations":"qwen.ai outage or maintenance; aggressive rate limiting from repeated probes; corporate proxy/WAF intercepting the request; API version bumped (v1 path removed).","solutions":["Retry after a short backoff — transient 5xx/429 usually clears.","Check qwen.ai service status; wait out rate limits before retrying.","Inspect the interpolated HTTP status: 429 -> backoff, 404 -> API changed, update the endpoint/library.","Verify network/proxy settings allow requests to chat.qwen.ai from the automation browser."],"exampleFix":"// before\nconst me = await verifyQwenIdentity(page);\n// after\nlet me;\nfor (let i = 0; i < 3; i++) {\n  try { me = await verifyQwenIdentity(page); break; }\n  catch (e) {\n    if (/HTTP (5\\d\\d|429)/.test(e.message) && i < 2) { await sleep(2000 * (i + 1)); continue; }\n    throw e;\n  }\n}","handlingStrategy":"retry","validationCode":"// basic reachability check before verification\nconst reachable = await fetch('https://chat.qwen.ai/').then(r => r.ok).catch(() => false);\nif (!reachable) { console.error('chat.qwen.ai unreachable - check network/proxy'); process.exit(2); }","typeGuard":"function isTransientHttpError(e) {\n  return /HTTP (5\\d\\d|429) from \\/api\\/v1\\/auths\\//.test(String(e?.message));\n}","tryCatchPattern":"try {\n  me = await verifyQwenIdentity(page);\n} catch (e) {\n  if (isTransientHttpError(e)) {\n    await sleep(5000);\n    me = await verifyQwenIdentity(page);\n  } else { throw e; }\n}","preventionTips":["Back off on 429/5xx before retrying","Monitor qwen.ai status during outages","Ensure proxies/WAFs allow chat.qwen.ai API traffic","Update the library if the API path version changes (404)"],"tags":["http","network","api"],"backgroundTag":"http-5xx-response","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}