jackwener/OpenCLI · error · AuthRequiredError
reddit.com: ${result.error}
Error message
reddit.com: ${result.error} What it means
Thrown by the reddit `saved` command when the in-page script returns a result with an `error` field that is NOT the 'Not logged in' case. The error is forwarded as `reddit.com: <error>` under CommandExecutionError (auth failures get the dedicated AuthRequiredError instead). It represents any other failure inside the page-context fetch/scrape of saved posts.
Source
Thrown at clis/reddit/saved.js:45
const limit = ${kwargs.limit};
const res = await fetch('/user/' + username + '/saved.json?limit=' + limit + '&raw_json=1', {
credentials: 'include'
});
const d = await res.json();
return (d?.data?.children || []).map(c => ({
title: c.data.title || c.data.body?.slice(0, 100) || '',
subreddit: c.data.subreddit_name_prefixed || 'r/' + (c.data.subreddit || '?'),
score: c.data.score || 0,
comments: c.data.num_comments || 0,
url: 'https://www.reddit.com' + (c.data.permalink || ''),
}));
} catch (e) {
return { error: e.toString() };
}
})()`);
if (result?.error) {
if (String(result.error).includes('Not logged in'))
throw new AuthRequiredError('reddit.com', result.error);
throw new CommandExecutionError(result.error);
}
return (result || []).slice(0, kwargs.limit);
}
});
View on GitHub (pinned to 49907e53dc)
Solutions
- Read the `result.error` text after the 'reddit.com:' prefix for the root cause
- Confirm the session is still valid — an expired session can surface as a non-auth-looking error; re-login and retry
- Update the CLI if Reddit changed its saved-posts endpoints/markup
- Retry after a delay if the error indicates a transient fetch failure
- Catch CommandExecutionError and degrade gracefully (show partial/empty saved list with a warning)
Example fix
// before
const saved = await runCli(['reddit', 'saved']);
// after
let saved;
try { saved = await runCli(['reddit', 'saved']); }
catch (e) { if (e.message.startsWith('reddit.com:')) { await loginReddit(); saved = await runCli(['reddit', 'saved']); } else throw e; } Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-check login state cheaply inside the session:
const me = await page.evaluate("fetch('/api/me.json?raw_json=1',{credentials:'include'}).then(r=>r.json())");
if (!me?.name) throw new Error('Not logged in — authenticate first'); Type guard
function isInPageError(r) {
return r != null && typeof r === 'object' && typeof r.error === 'string' && !r.error.includes('Not logged in');
} Try / catch
try {
const saved = await runCli(['reddit', 'saved']);
} catch (e) {
if (e.message.startsWith('reddit.com:')) {
console.error('Saved-list scrape failed:', e.message.slice('reddit.com:'.length));
await loginReddit(); // refresh session, then retry once
} else throw e;
} Prevention
- Refresh the session periodically — stale sessions cause odd in-page errors
- Update the package when Reddit changes its saved-list endpoints
- Retry with backoff for transient fetch failures inside the page
When it happens
Trigger: The page.evaluate script catches an exception and returns { error: e.toString() }, and the string does not contain 'Not logged in' — e.g. fetch failures inside reddit.com, unexpected JSON shapes, or DOM/API changes breaking the scrape.
Common situations: Reddit changing the saved-posts API or markup; rate limiting causing in-page fetches to fail; the saved list being huge and a chunked request failing; CORS/credentials anomalies after a session refresh.
Related errors
- ${result.error}
- Not a git repository
- Working tree not clean: ${status}
- 1point3acres thread
- 1point3acres user
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/d88c17c1d2c02bd0.
Report an issue: GitHub.