jackwener/OpenCLI · error · AuthRequiredError

reddit.com

reddit.com

Error message

reddit.com: ${result.detail}

What it means

An envelope kind of 'auth' means Reddit returned a login/permission challenge for the request. The command raises AuthRequiredError scoped to host 'reddit.com' with the script's detail message, indicating the cookie-based session is missing or no longer authorized.

Source

Thrown at clis/reddit/read.js:569

        // If we produced nothing beyond the POST row but the comment listing
        // wasn't empty, that's parser drift (e.g. Reddit changed t1/more
        // schema). Surface as CommandExecutionError on the Node side.
        if (rows.length <= 1 && preWalkSize > 0 && t1TopLevel.length > 0) {
          return { kind: 'parser-drift', detail: 'Reddit comment listing for post ' + postId + ' had ' + t1TopLevel.length + ' t1 entries but walker produced no rows.' };
        }

        return { kind: 'ok', rows: rows, expandMeta: expandMeta };
      })()
    `);

        if (!result || typeof result !== 'object') {
            throw new CommandExecutionError('Reddit /comments fetch returned no result envelope.');
        }
        if (result.kind === 'inaccessible') {
            throw new EmptyResultError(result.detail);
        }
        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 === 'parser-drift') {
            throw new CommandExecutionError(result.detail);
        }
        if (result.kind === 'expand-failed') {
            throw new CommandExecutionError(result.detail);
        }
        if (result.kind !== 'ok' || !Array.isArray(result.rows)) {
            throw new CommandExecutionError(`Unexpected result from reddit read: ${JSON.stringify(result)}`);
        }
        return result.rows;
    },

View on GitHub (pinned to 49907e53dc)

Solutions

  1. Re-authenticate: refresh the stored reddit.com cookies via the CLI's auth/login flow.
  2. Log in to reddit.com in the browser session the tool uses, then retry.
  3. If Reddit is challenging your IP, retry from a residential network or after completing any captcha manually.
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-check session cookies before calling
const hasSession = await page.cookies('https://www.reddit.com').then(cs => cs.some(c => c.name === 'session_token' || c.name.startsWith('token')));
if (!hasSession) await runAuthFlow('reddit.com');

Type guard

null

Try / catch

try {
  return await redditRead(postId);
} catch (e) {
  if (e instanceof AuthRequiredError) {
    await refreshRedditCookies();
    return redditRead(postId);
  }
  throw e;
}

Prevention

When it happens

Trigger: Expired or absent reddit.com session cookies while fetching a post that requires login (or any request Reddit answers with a login redirect/challenge).

Common situations: Cookies expired after a logout or password change; running headless without ever authenticating; Reddit aggressively challenging a datacenter IP.

Related errors


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