jackwener/OpenCLI · error · CommandExecutionError

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

Error message

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

What it means

This CommandExecutionError is thrown by the reddit whoami CLI when the internal script executed in the page/binary context reports kind === 'http', meaning the whoami HTTP request completed but Reddit returned a non-success HTTP status (result.httpStatus) from endpoint result.where. The CLI wraps any non-auth HTTP failure as a command execution error so callers see the status code and the URL that failed. It signals the request reached Reddit but was rejected at the transport/status level, not an authentication-cookie problem (that path throws AuthRequiredError instead).

Source

Thrown at clis/reddit/whoami.js:49

        if (!res.ok) {
          return { kind: 'http', httpStatus: res.status, where: '/api/me.json' };
        }
        const d = await res.json();
        const me = d?.data;
        if (!me?.name) {
          return { kind: 'auth', detail: 'Not logged in to reddit.com (no identity in /api/me.json)' };
        }
        return { kind: 'ok', identity: me };
      } 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(`whoami failed: ${result.detail}`);
        }
        if (result?.kind !== 'ok') {
            throw new CommandExecutionError(`Unexpected result from reddit whoami: ${JSON.stringify(result)}`);
        }

        const u = result.identity;
        const created = u.created_utc
            ? new Date(u.created_utc * 1000).toISOString().split('T')[0]
            : null;
        const linkKarma = typeof u.link_karma === 'number' ? u.link_karma : null;
        const commentKarma = typeof u.comment_karma === 'number' ? u.comment_karma : null;
        const totalKarma = typeof u.total_karma === 'number'
            ? u.total_karma
            : (linkKarma != null && commentKarma != null ? linkKarma + commentKarma : null);
        const inboxCount = typeof u.inbox_count === 'number' ? u.inbox_count : null;

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Read result.httpStatus and result.where from the message to identify which endpoint failed and how, then address that specific status (403 => IP/bot detection, 429 => back off, 5xx => retry later).
  2. Wait and retry with exponential backoff if the status is 429 or 5xx; reduce polling frequency of whoami.
  3. If 403, switch egress IP (disable proxy/VPN or use a residential IP) or clear browser fingerprint flags that trigger Reddit's WAF.
  4. Verify the session is still valid by re-authenticating; an expired-but-present cookie can yield unexpected statuses rather than a clean auth failure.
  5. Catch CommandExecutionError in calling code and surface result.httpStatus to distinguish transient from permanent failures.

Example fix

// before: hammering whoami in a tight loop, hitting 429
for (const id of ids) { await whoami(client); }

// after: retry with backoff on transient statuses
const res = await withBackoff(() => whoami(client), {
  retryOn: (e) => /HTTP (429|5\d\d) from/.test(e.message)
});
Defensive patterns

Strategy: retry

Type guard

function isHttpStatusError(e) {
  return e instanceof CommandExecutionError && /HTTP \d{3} from /.test(e.message);
}
function statusOf(e) {
  const m = e.message.match(/HTTP (\d{3}) from /);
  return m ? Number(m[1]) : null;
}

Try / catch

try {
  await whoami();
} catch (e) {
  if (isHttpStatusError(e)) {
    const s = statusOf(e);
    if (s === 429 || s >= 500) await backoffRetry(whoami, 3);
    else throw e; // 403 etc. won't fix itself
  } else throw e;
}

Prevention

When it happens

Trigger: Running the `whoami` command for reddit when the underlying whoami result object has kind='http'; i.e., the request to reddit.com returned a status code outside the success range (e.g., 403, 429, 500, 503) while a valid session cookie was still present.

Common situations: Reddit rate-limiting the client (HTTP 429) after rapid repeated whoami calls; Reddit edge/WAF returning 403 for flagged IPs or datacenter egress; transient Reddit 5xx outages; proxy/VPN interfering so requests are blocked with a non-200 status even though the session cookie exists.

Related errors


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