jackwener/OpenCLI · error · AuthRequiredError

reddit.com: ${result.detail}

Error message

reddit.com: ${result.detail}

What it means

clis/reddit/subscribed.js throws AuthRequiredError('reddit.com', result.detail) when the in-browser fetch returns the 'auth' kind sentinel, meaning the Reddit session cookies were rejected while listing subscribed subreddits. The library models 'you must be logged in to reddit.com in the browser' as a typed, domain-tagged error instead of a generic failure. The browser-side sentinel is converted to the typed error on the Node side so callers can branch on it.

Source

Thrown at clis/reddit/subscribed.js:145

            return { kind: 'malformed', detail: 'Reddit subscriptions repeated pagination cursor ' + next + '.' };
          }
          seenCursors.add(next);
          after = next;
        }
        if (out.length < target && after) {
          return { kind: 'malformed', detail: 'Reddit subscriptions pagination exceeded the safety cap before satisfying the requested limit.' };
        }
        return { kind: 'ok', entries: out };
      } catch (e) {
        return { kind: 'exception', detail: String(e && e.message || e) };
      }
    })()`));
        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)

Solutions

  1. Open Chrome/Chromium (the profile the CLI is attached to) and log in to https://www.reddit.com, then rerun the command.
  2. Verify the CLI is connected to the intended browser profile that holds the Reddit session, not a clean profile.
  3. If cookies were recently invalidated (logout, password change), re-authenticate and confirm reddit.com/me.json loads in the browser.
  4. Catch AuthRequiredError in wrapper scripts and surface the login hint instead of retrying.

Example fix

// before
result = await redditSubscribed(); // throws AuthRequiredError('reddit.com')
// after
import { AuthRequiredError } from '@jackwener/opencli/errors';
try {
  result = await redditSubscribed();
} catch (e) {
  if (e instanceof AuthRequiredError) {
    console.error('Login to reddit.com in the attached browser, then retry.');
    process.exit(e.exitCode);
  }
  throw e;
}
Defensive patterns

Strategy: try-catch

Validate before calling

// preflight: check session before calling
try { await run(['reddit', 'whoami']); } catch (e) { if (e instanceof AuthRequiredError) throw new Error('Login to reddit.com first'); }

Type guard

function isAuthRequiredError(e) { return e instanceof AuthRequiredError; }

Try / catch

try {
  const rows = await run(['reddit', 'subscribed']);
} catch (e) {
  if (e instanceof AuthRequiredError && e.domain === 'reddit.com') {
    // prompt user to log in via the attached browser; do not retry
    return;
  }
  throw e;
}

Prevention

When it happens

Trigger: Running the `reddit subscribed` command when the connected Chrome/Chromium profile has no valid Reddit session; the page.evaluate fetch of the subscribed list returns {kind:'auth', detail:...} and the CLI converts it at subscribed.js:145.

Common situations: User never logged into Reddit in the automation browser; Reddit session cookies expired or were invalidated (password change, logout on another device); running the CLI against a fresh/blank Chrome profile; Reddit rate-limiting or clearing cookies via cloudflare-style challenge.

Related errors


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