{"record":{"id":"6160d60703be9d4b","repo":"jackwener/OpenCLI","slug":"http-result-httpstatus-from-result-where","errorCode":null,"errorMessage":"HTTP ${result.httpStatus} from ${result.where}","messagePattern":"HTTP (.+?) from (.+?)","errorType":"exception","errorClass":"CommandExecutionError","httpStatus":null,"severity":"error","filePath":"clis/reddit/home.js","lineNumber":112,"sourceCode":"        if (!res.ok) {\n          return { kind: 'http', httpStatus: res.status, where: '/best.json' };\n        }\n        const j = await res.json();\n        const entries = j?.data?.children;\n        if (!Array.isArray(entries)) {\n          return { kind: 'http', httpStatus: 200, where: '/best.json (no data.children array)' };\n        }\n        return { kind: 'ok', entries };\n      } catch (e) {\n        return { kind: 'exception', detail: String(e && e.message || e) };\n      }\n    })()`);\n\n        if (result?.kind === 'auth') {\n            throw new AuthRequiredError('reddit.com', result.detail);\n        }\n        if (result?.kind === 'http') {\n            throw new CommandExecutionError(`HTTP ${result.httpStatus} from ${result.where}`);\n        }\n        if (result?.kind === 'exception') {\n            throw new CommandExecutionError(`home failed: ${result.detail}`);\n        }\n        if (result?.kind !== 'ok') {\n            throw new CommandExecutionError(`Unexpected result from reddit home: ${JSON.stringify(result)}`);\n        }\n\n        const rows = [];\n        const entries = result.entries.slice(0, limit);\n        for (let i = 0; i < entries.length; i++) {\n            const d = entries[i]?.data;\n            if (!d || !d.id) continue;\n            rows.push({\n                rank: i + 1,\n                title: typeof d.title === 'string' ? d.title : null,\n                subreddit: typeof d.subreddit_name_prefixed === 'string' ? d.subreddit_name_prefixed : null,\n                score: typeof d.score === 'number' ? d.score : null,","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/reddit/home.js#L94-L130","documentation":"CommandExecutionError thrown by `reddit home` when the in-page probe returns kind==='http': /api/me.json or /best.json responded with a non-OK status other than 401/403 (or the /best.json payload lacked a data.children array, reported as HTTP 200 with that note in `where`). It indicates a Reddit-side or protocol-level failure, not a login problem.","triggerScenarios":"Reddit returning 429 (rate limit), 5xx (outage/degraded), or 200 with a malformed /best.json payload missing data.children — the message names the exact endpoint via `where`.","commonSituations":"Polling home too aggressively causing 429s; Reddit incidents returning 5xx; Reddit changing the /best.json response shape (no data.children); CDN edge errors for your region.","solutions":["Retry after a delay; check https://www.redditstatus.com if statuses are 5xx.","Back off on 429 — reduce poll frequency or add exponential backoff.","Read `where` in the message: if it says '/best.json (no data.children array)', the API shape likely changed — update the library or pin a known-good version.","Rule out proxy/CDN interference by fetching /best.json from a normal browser on the same network."],"exampleFix":"// before: tight loop\nfor (const _ of Array(20)) await runHome();\n// after: backoff\nfor (let i = 0; i < 20; i++) { try { await runHome(); } catch (e) { await new Promise(r => setTimeout(r, 2 ** i * 1000)); } }","handlingStrategy":"retry","validationCode":"// health-check the endpoints before the command\nconst probe = await fetch('https://www.reddit.com/best.json?limit=1&raw_json=1', { credentials: 'include' });\nif (!probe.ok && probe.status !== 401 && probe.status !== 403) {\n  console.warn(`Reddit degraded (HTTP ${probe.status}); retrying later.`);\n}","typeGuard":null,"tryCatchPattern":"try {\n  const feed = await opencli.reddit.home({ limit: 25 });\n} catch (e) {\n  if (/HTTP \\d+ from/.test(e.message) && attempts < 3) {\n    await sleep(2 ** attempts * 5000);\n    return retry();\n  }\n  if (/no data\\.children/.test(e.message)) {\n    console.error('/best.json shape changed — update the library.');\n  }\n  throw e;\n}","preventionTips":["Apply exponential backoff, especially on 429s.","Check redditstatus.com when seeing 5xx before debugging locally.","Pin/update library versions when Reddit changes the listing response shape.","Avoid very tight polling loops against Reddit endpoints."],"tags":["reddit","http","rate-limit","api-shape"],"backgroundTag":"http-5xx-response","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}