jackwener/OpenCLI · error · CommandExecutionError

HTTP ${result.httpStatus} from ${result.where}

Error message

HTTP ${result.httpStatus} from ${result.where}

What it means

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.

Source

Thrown at clis/reddit/home.js:112

        if (!res.ok) {
          return { kind: 'http', httpStatus: res.status, where: '/best.json' };
        }
        const j = await res.json();
        const entries = j?.data?.children;
        if (!Array.isArray(entries)) {
          return { kind: 'http', httpStatus: 200, where: '/best.json (no data.children array)' };
        }
        return { kind: 'ok', entries };
      } catch (e) {
        return { kind: 'exception', detail: String(e && e.message || e) };
      }
    })()`);

        if (result?.kind === 'auth') {
            throw new AuthRequiredError('reddit.com', result.detail);
        }
        if (result?.kind === 'http') {
            throw new CommandExecutionError(`HTTP ${result.httpStatus} from ${result.where}`);
        }
        if (result?.kind === 'exception') {
            throw new CommandExecutionError(`home failed: ${result.detail}`);
        }
        if (result?.kind !== 'ok') {
            throw new CommandExecutionError(`Unexpected result from reddit home: ${JSON.stringify(result)}`);
        }

        const rows = [];
        const entries = result.entries.slice(0, limit);
        for (let i = 0; i < entries.length; i++) {
            const d = entries[i]?.data;
            if (!d || !d.id) continue;
            rows.push({
                rank: i + 1,
                title: typeof d.title === 'string' ? d.title : null,
                subreddit: typeof d.subreddit_name_prefixed === 'string' ? d.subreddit_name_prefixed : null,
                score: typeof d.score === 'number' ? d.score : null,

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Retry after a delay; check https://www.redditstatus.com if statuses are 5xx.
  2. Back off on 429 — reduce poll frequency or add exponential backoff.
  3. 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.
  4. Rule out proxy/CDN interference by fetching /best.json from a normal browser on the same network.

Example fix

// before: tight loop
for (const _ of Array(20)) await runHome();
// after: backoff
for (let i = 0; i < 20; i++) { try { await runHome(); } catch (e) { await new Promise(r => setTimeout(r, 2 ** i * 1000)); } }
Defensive patterns

Strategy: retry

Validate before calling

// health-check the endpoints before the command
const probe = await fetch('https://www.reddit.com/best.json?limit=1&raw_json=1', { credentials: 'include' });
if (!probe.ok && probe.status !== 401 && probe.status !== 403) {
  console.warn(`Reddit degraded (HTTP ${probe.status}); retrying later.`);
}

Try / catch

try {
  const feed = await opencli.reddit.home({ limit: 25 });
} catch (e) {
  if (/HTTP \d+ from/.test(e.message) && attempts < 3) {
    await sleep(2 ** attempts * 5000);
    return retry();
  }
  if (/no data\.children/.test(e.message)) {
    console.error('/best.json shape changed — update the library.');
  }
  throw e;
}

Prevention

When it happens

Trigger: 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`.

Common situations: 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.

Related errors


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/6160d60703be9d4b. Report an issue: GitHub.