{"record":{"id":"e4f8e5ace107cf8a","repo":"jackwener/OpenCLI","slug":"http-result-httpstatus-from-api-me-json","errorCode":null,"errorMessage":"HTTP ${result.httpStatus} from /api/me.json","messagePattern":"HTTP (.+?) from /api/me\\.json","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/reddit/auth.js","lineNumber":33,"sourceCode":"  const result = await page.evaluate(`(async () => {\n    try {\n      const res = await fetch('/api/me.json', { credentials: 'include', headers: { 'Accept': 'application/json' } });\n      if (res.status === 401 || res.status === 403) {\n        return { kind: 'auth', detail: 'Reddit /api/me.json HTTP ' + res.status };\n      }\n      if (!res.ok) return { kind: 'http', httpStatus: res.status };\n      const d = await res.json();\n      const data = d && d.data;\n      if (!data || !data.name) {\n        return { kind: 'auth', detail: 'Reddit /api/me.json 200 but no data.name — anonymous' };\n      }\n      return { ok: true, username: String(data.name), id: String(data.id || '') };\n    } catch (e) {\n      return { kind: 'exception', detail: String(e && e.message || e) };\n    }\n  })()`);\n  if (result?.kind === 'auth') throw new AuthRequiredError('reddit.com', result.detail);\n  if (result?.kind === 'http') throw new CommandExecutionError(`HTTP ${result.httpStatus} from /api/me.json`);\n  if (result?.kind === 'exception') throw new CommandExecutionError(`Reddit whoami failed: ${result.detail}`);\n  if (!result?.ok) throw new CommandExecutionError(`Unexpected Reddit probe: ${JSON.stringify(result)}`);\n  return { username: result.username, id: result.id };\n}\n\nregisterSiteAuthCommands({\n  site: 'reddit',\n  domain: 'reddit.com',\n  loginUrl: 'https://www.reddit.com/login',\n  columns: ['username', 'id'],\n  quickCheck: hasRedditSessionCookie,\n  verify: verifyRedditIdentity,\n  poll: async (page) => {\n    if (!await hasRedditSessionCookie(page)) {\n      throw new AuthRequiredError('reddit.com', 'Waiting for Reddit reddit_session cookie');\n    }\n    return verifyRedditIdentity(page);\n  },","sourceCodeStart":15,"sourceCodeEnd":51,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/reddit/auth.js#L15-L51","documentation":"CommandExecutionError thrown when the in-page fetch of /api/me.json in verifyRedditIdentity returns a non-OK status other than 401/403. Unlike the auth kinds, this is treated as a general HTTP failure of the identity probe, not a login problem.","triggerScenarios":"Reddit's /api/me.json responds with 5xx or other unexpected statuses (e.g. 429 rate limit, 502/503 from Reddit's edge) while the session cookie passes the quick cookie check.","commonSituations":"Reddit outage or degraded service; aggressive polling tripping Reddit rate limiting (429); corporate proxy intercepting and returning its own error status.","solutions":["Wait briefly and retry; check https://www.redditstatus.com for a Reddit outage.","Reduce polling frequency — a 429 means you're being rate-limited; back off.","Inspect the status in the message; if it's 429 add delays/backoff around repeated auth checks.","Verify no proxy/VPN is injecting error responses for www.reddit.com."],"exampleFix":"// before: tight poll loop hitting /api/me.json\nwhile (true) { await verifyRedditIdentity(page); }\n// after: backoff on failure\ntry { await verifyRedditIdentity(page); } catch (e) { await new Promise(r => setTimeout(r, 30_000)); }","handlingStrategy":"retry","validationCode":"// probe Reddit availability first\nconst health = await fetch('https://www.reddit.com/api/me.json');\nif (health.status >= 500 || health.status === 429) await backoff();","typeGuard":null,"tryCatchPattern":"try {\n  await opencli.reddit.whoami();\n} catch (e) {\n  if (/HTTP \\d+ from \\/api\\/me\\.json/.test(e.message) && attempts < 3) {\n    await sleep(5000 * attempts);\n    return retry();\n  }\n  throw e;\n}","preventionTips":["Add exponential backoff around Reddit probes.","Watch for 429 and reduce polling frequency accordingly.","Monitor redditstatus.com during incidents instead of hammering the API.","Route through a stable network; avoid proxies that inject error statuses."],"tags":["reddit","http","network","rate-limit"],"backgroundTag":"http-5xx-response","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}