jackwener/OpenCLI · error · CommandExecutionError

Unexpected result from reddit subscribed

Error message

Unexpected result from reddit subscribed: ${JSON.stringify(result)}

What it means

If none of the known result kinds matched (not ok/auth/http/malformed/exception) or result.entries is not an array, subscribed.js throws CommandExecutionError including the full JSON of the result. This is a contract check: the browser probe returned an unrecognized shape, so the CLI refuses to guess and surfaces the raw payload for diagnosis. It usually indicates a version mismatch or unexpected Reddit response envelope.

Solutions

  1. Inspect the JSON dumped in the message to see the actual result shape.
  2. Update both the CLI and the browser extension/daemon to matching versions so the sentinel contract holds.
  3. Retry the command — a transient evaluate failure can yield an empty result.
  4. If Reddit changed the payload, patch the scraper's kind/entries contract.
Defensive patterns

Strategy: type-guard

Type guard

function isWellFormedResult(r) {
  return r != null && typeof r === 'object' && typeof r.kind === 'string' &&
    (r.kind !== 'ok' || Array.isArray(r.entries));
}

Try / catch

try {
  await run(['reddit', 'subscribed']);
} catch (e) {
  if (e.message.startsWith('Unexpected result from reddit subscribed:')) {
    const payload = JSON.parse(e.message.slice(e.message.indexOf(':') + 2));
    log.debug('raw result', payload); // diagnose version mismatch
  } else throw e;
}

Prevention

When it happens

Trigger: page.evaluate resolves to undefined/null or an object without kind/entries (e.g. older browser bridge, script truncated, evaluate failed silently); result.entries missing when kind==='ok'.

Common situations: Mismatched versions of the CLI and its browser extension/daemon; the evaluate promise rejected in a way producing undefined; Reddit returning ok with a differently shaped payload after an API change.

Related errors


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

Appendix: source

Thrown at clis/reddit/subscribed.js:157

    })()`));
        if (result?.kind === 'login-wall') {
            // Convert the browser-side sentinel into a typed LoginWallError on the Node side.
            throwIfLoginWall(result.sentinel, { url: result.where });
        }
        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 === 'malformed') {
            throw new CommandExecutionError(result.detail);
        }
        if (result?.kind === 'exception') {
            throw new CommandExecutionError(`subscribed failed: ${result.detail}`);
        }
        if (result?.kind !== 'ok' || !Array.isArray(result.entries)) {
            throw new CommandExecutionError(`Unexpected result from reddit subscribed: ${JSON.stringify(result)}`);
        }
        const rows = result.entries.slice(0, limit).map((entry, index) => mapSubredditRow(entry, index));
        if (rows.length === 0) {
            throw new EmptyResultError('Reddit returned no subscribed subreddits for the logged-in account.');
        }
        return rows;
    }
});

View on GitHub (pinned to 49907e53dc)