jackwener/OpenCLI · warning · ArgumentError
limit must be an integer in [1, ${REDDIT_SUBSCRIBED_MAX_LIMI
Error message
limit must be an integer in [1, ${REDDIT_SUBSCRIBED_MAX_LIMIT}]. What it means
ArgumentError thrown by parseRedditSubscribedLimit when the `limit` argument is not an integer in [1, 1000]. The limit controls how many subscribed subreddits to fetch (auto-paginating in pages of 100), and the library validates it up front to fail fast instead of mid-pagination.
Source
Thrown at clis/reddit/subscribed.js:11
import { ArgumentError, AuthRequiredError, CommandExecutionError, EmptyResultError } from '@jackwener/opencli/errors';
import { cli, Strategy } from '@jackwener/opencli/registry';
import { BROWSER_JSON_SNIFF_FN, throwIfLoginWall } from '@jackwener/opencli/utils';
export const REDDIT_SUBSCRIBED_MAX_LIMIT = 1000;
export function parseRedditSubscribedLimit(raw) {
if (raw === undefined || raw === null || raw === '') return 100;
const n = Number(raw);
if (!Number.isFinite(n) || !Number.isInteger(n) || n < 1 || n > REDDIT_SUBSCRIBED_MAX_LIMIT) {
throw new ArgumentError(
`limit must be an integer in [1, ${REDDIT_SUBSCRIBED_MAX_LIMIT}].`,
`Got: ${raw}`,
);
}
return n;
}
export function unwrapEvaluateResult(payload) {
if (payload && typeof payload === 'object' && !Array.isArray(payload) && 'session' in payload && 'data' in payload) {
return payload.data;
}
return payload;
}
function mapSubredditRow(entry, index) {
const data = entry?.data;
if (!data || typeof data !== 'object') {
throw new CommandExecutionError(`Reddit subscriptions row ${index + 1} was missing data.`);View on GitHub (pinned to 49907e53dc)
Solutions
- Pass an integer between 1 and 1000, e.g. limit=100
- Use 'all-like' behavior by passing 1000 (the maximum) rather than 0 or a huge number
- Trim/normalize the input: strip whitespace and units so Number(raw) is a clean integer
- If sourcing limit from config/env, coerce and validate before calling, e.g. Number.isInteger(Number(v))
Example fix
// before reddit subscribed --limit 0 // throws reddit subscribed --limit 'all' // throws // after reddit subscribed --limit 1000 // max valid value
Defensive patterns
Strategy: validation
Validate before calling
const REDDIT_SUBSCRIBED_MAX_LIMIT = 1000;
function validLimit(v){
if (v === undefined || v === null || v === '') return 100;
const n = Number(v);
return Number.isInteger(n) && n >= 1 && n <= REDDIT_SUBSCRIBED_MAX_LIMIT ? n : null;
} Type guard
function isValidLimit(v){
if (v === undefined || v === null || v === '') return true;
const n = Number(v);
return Number.isInteger(n) && n >= 1 && n <= 1000;
} Try / catch
try { await cli.redditSubscribed({ limit }); }
catch (e) { if (e.name === 'ArgumentError' && e.message.includes('limit must be an integer')) { console.error(`bad limit ${limit}; use 1-1000`); return; } throw e; } Prevention
- Clamp user-supplied limits: Math.min(1000, Math.max(1, n)) before passing
- Never use 0 to mean 'unlimited' — use 1000 (the max)
- Coerce config/env strings with Number() and Number.isInteger checks
- Reuse the exported parseRedditSubscribedLimit for pre-validation in embeddings
When it happens
Trigger: Passing limit values like 0, -5, 1001, 12.5, 'abc', or NaN to the reddit subscribed command; omitting it is fine (defaults to 100), but any present value must parse as a finite integer within range.
Common situations: Users assuming '0' means 'unlimited'; copying limits above Reddit's max; passing a string with whitespace or units ('100 subs'); config files with float or string values.
Related errors
- ${label} must be a non-negative integer, got ${JSON.stringif
- limit must be a positive integer
- archive wayback timestamp must be YYYY[MM[DD[hh[mm[ss]]]]] o
- archive wayback url cannot be empty
- bilibili comment ${label} must be a positive integer
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/fc3ea894df835c14.
Report an issue: GitHub.