{"record":{"id":"034a4b9c58a62f4e","repo":"jackwener/OpenCLI","slug":"reddit-com-result-detail-034a4b","errorCode":null,"errorMessage":"reddit.com: ${result.detail}","messagePattern":"reddit\\.com: (.+?)","errorType":"error_code","errorClass":"AuthRequiredError","httpStatus":null,"severity":"error","filePath":"clis/reddit/subscribed.js","lineNumber":145,"sourceCode":"            return { kind: 'malformed', detail: 'Reddit subscriptions repeated pagination cursor ' + next + '.' };\n          }\n          seenCursors.add(next);\n          after = next;\n        }\n        if (out.length < target && after) {\n          return { kind: 'malformed', detail: 'Reddit subscriptions pagination exceeded the safety cap before satisfying the requested limit.' };\n        }\n        return { kind: 'ok', entries: out };\n      } catch (e) {\n        return { kind: 'exception', detail: String(e && e.message || e) };\n      }\n    })()`));\n        if (result?.kind === 'login-wall') {\n            // Convert the browser-side sentinel into a typed LoginWallError on the Node side.\n            throwIfLoginWall(result.sentinel, { url: result.where });\n        }\n        if (result?.kind === 'auth') {\n            throw new AuthRequiredError('reddit.com', result.detail);\n        }\n        if (result?.kind === 'http') {\n            throw new CommandExecutionError(`HTTP ${result.httpStatus} from ${result.where}`);\n        }\n        if (result?.kind === 'malformed') {\n            throw new CommandExecutionError(result.detail);\n        }\n        if (result?.kind === 'exception') {\n            throw new CommandExecutionError(`subscribed failed: ${result.detail}`);\n        }\n        if (result?.kind !== 'ok' || !Array.isArray(result.entries)) {\n            throw new CommandExecutionError(`Unexpected result from reddit subscribed: ${JSON.stringify(result)}`);\n        }\n        const rows = result.entries.slice(0, limit).map((entry, index) => mapSubredditRow(entry, index));\n        if (rows.length === 0) {\n            throw new EmptyResultError('Reddit returned no subscribed subreddits for the logged-in account.');\n        }\n        return rows;","sourceCodeStart":127,"sourceCodeEnd":163,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/reddit/subscribed.js#L127-L163","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Open Chrome/Chromium (the profile the CLI is attached to) and log in to https://www.reddit.com, then rerun the command.","Verify the CLI is connected to the intended browser profile that holds the Reddit session, not a clean profile.","If cookies were recently invalidated (logout, password change), re-authenticate and confirm reddit.com/me.json loads in the browser.","Catch AuthRequiredError in wrapper scripts and surface the login hint instead of retrying."],"exampleFix":"// before\nresult = await redditSubscribed(); // throws AuthRequiredError('reddit.com')\n// after\nimport { AuthRequiredError } from '@jackwener/opencli/errors';\ntry {\n  result = await redditSubscribed();\n} catch (e) {\n  if (e instanceof AuthRequiredError) {\n    console.error('Login to reddit.com in the attached browser, then retry.');\n    process.exit(e.exitCode);\n  }\n  throw e;\n}","handlingStrategy":"try-catch","validationCode":"// preflight: check session before calling\ntry { await run(['reddit', 'whoami']); } catch (e) { if (e instanceof AuthRequiredError) throw new Error('Login to reddit.com first'); }","typeGuard":"function isAuthRequiredError(e) { return e instanceof AuthRequiredError; }","tryCatchPattern":"try {\n  const rows = await run(['reddit', 'subscribed']);\n} catch (e) {\n  if (e instanceof AuthRequiredError && e.domain === 'reddit.com') {\n    // prompt user to log in via the attached browser; do not retry\n    return;\n  }\n  throw e;\n}","preventionTips":["Keep the automation Chrome profile logged in to reddit.com","Run `reddit whoami` as a preflight auth check in scripts","Re-login after password changes or known cookie expiry","Do not share/clear the profile's cookie store while the CLI runs"],"tags":["authentication","reddit","browser-session"],"backgroundTag":"site-login-required","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}