{"record":{"id":"b98ebf3471e8877d","repo":"jackwener/OpenCLI","slug":"http-result-httpstatus-from-web-user","errorCode":null,"errorMessage":"HTTP ${result.httpStatus} from /web/user","messagePattern":"HTTP (.+?) from /web/user","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/weread/auth.js","lineNumber":40,"sourceCode":"      if (res.status === 401 || res.status === 403) {\n        return { kind: 'auth', detail: 'WeRead /web/user HTTP ' + res.status };\n      }\n      if (!res.ok) return { kind: 'http', httpStatus: res.status };\n      const d = await res.json();\n      if (d && d.errCode && d.errCode !== 0) {\n        return { kind: 'auth', detail: 'WeRead /web/user errCode=' + d.errCode };\n      }\n      return {\n        ok: true,\n        user_id: String(d.userVid || wrVid),\n        name: String(d.name || d.nickName || ''),\n      };\n    } catch (e) {\n      return { kind: 'exception', detail: String(e && e.message || e) };\n    }\n  })()`);\n  if (result?.kind === 'auth') throw new AuthRequiredError('weread.qq.com', result.detail);\n  if (result?.kind === 'http') throw new CommandExecutionError(`HTTP ${result.httpStatus} from /web/user`);\n  if (result?.kind === 'exception') throw new CommandExecutionError(`WeRead whoami failed: ${result.detail}`);\n  if (!result?.ok) throw new CommandExecutionError(`Unexpected WeRead probe: ${JSON.stringify(result)}`);\n  return { user_id: result.user_id, name: result.name };\n}\n\nregisterSiteAuthCommands({\n  site: 'weread',\n  domain: 'weread.qq.com',\n  loginUrl: 'https://weread.qq.com/',\n  columns: ['user_id', 'name'],\n  quickCheck: hasWereadSessionCookie,\n  verify: verifyWereadIdentity,\n  poll: async (page) => {\n    if (!await hasWereadSessionCookie(page)) {\n      throw new AuthRequiredError('weread.qq.com', 'Waiting for WeRead wr_vid cookie');\n    }\n    return verifyWereadIdentity(page);\n  },","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/weread/auth.js#L22-L58","documentation":"verifyWereadIdentity in clis/weread/auth.js throws CommandExecutionError when the in-page probe to /web/user returns kind:'http' — the endpoint responded with an HTTP error status other than 401/403 (those are treated as auth failures). This means an unexpected server-side HTTP failure during the identity check.","triggerScenarios":"Inside page.evaluate, fetch('/web/user', {credentials:'include'}) returns e.g. 404, 429, 500, 502, 503 — WeRead server error, endpoint renamed/moved, or rate limiting.","commonSituations":"WeRead outage or partial degradation (5xx); rate limiting (429) after rapid polling; WeRead changing/removing the /web/user path in a site update.","solutions":["Retry after a delay — 5xx/429 are usually transient; reduce polling frequency if 429.","Check WeRead service status by loading weread.qq.com/web/user in the browser.","Update the CLI if WeRead changed the endpoint path (a persistent 404 suggests an API change).","Run `weread login` verification again once the server recovers."],"exampleFix":"// before: hammering during outage\n$ opencli weread whoami\nCommandExecutionError: HTTP 502 from /web/user\n// after: wait and retry\n$ sleep 30 && opencli weread whoami","handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"for (let i = 0; i < 3; i++) {\n  try { return await verifyWereadIdentity(page); }\n  catch (e) { if (!/HTTP \\d+ from \\/web\\/user/.test(e.message) || i === 2) throw e; await new Promise(r => setTimeout(r, 3000 * (i + 1))); }\n}","preventionTips":["Back off on 429/5xx before re-probing","Reduce polling frequency for login verification","Check weread.qq.com availability in a browser during outages","Update the CLI if /web/user persistently 404s (API change)"],"tags":["network","http","weread","whoami"],"backgroundTag":"http-request-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}