jackwener/OpenCLI · error · ArgumentError
Invalid interval: ${JSON.stringify(rawValue)}. Expected an i
Error message
Invalid interval: ${JSON.stringify(rawValue)}. Expected an integer from 0 to ${MAX_INTERVAL_SECONDS}. What it means
parseBatchIntervalSeconds (the `interval` option of batch commands) converts the raw value to a Number and requires an integer between 0 and MAX_INTERVAL_SECONDS (600). Out-of-range, fractional, or non-numeric values throw ArgumentError quoting the original input; empty/undefined/null defaults to 5 seconds.
Source
Thrown at clis/twitter/list-batch-utils.js:42
for (const username of values) {
if (!USERNAME_RE.test(username)) {
throw new ArgumentError(`Invalid Twitter/X username: ${JSON.stringify(username)}`, example);
}
const key = username.toLowerCase();
if (seen.has(key)) continue;
seen.add(key);
usernames.push(username);
}
return usernames;
}
export function parseBatchIntervalSeconds(rawValue) {
const value = rawValue === undefined || rawValue === null || rawValue === ''
? DEFAULT_INTERVAL_SECONDS
: Number(rawValue);
if (!Number.isInteger(value) || value < 0 || value > MAX_INTERVAL_SECONDS) {
throw new ArgumentError(`Invalid interval: ${JSON.stringify(rawValue)}. Expected an integer from 0 to ${MAX_INTERVAL_SECONDS}.`);
}
return value;
}
export function toBatchFailureRow({ listId, username, error }) {
return {
listId,
username,
userId: '',
status: 'failed',
message: error?.message || String(error),
};
}
function isGlobalBatchFailure(error) {
if (error instanceof ArgumentError || error instanceof AuthRequiredError) {
return true;
}View on GitHub (pinned to 49907e53dc)
Solutions
- Pass a plain integer of seconds in 0–600: --interval 30.
- Convert milliseconds to seconds in your script (5000 ms → 5).
- Omit the flag entirely to use the default of 5 seconds.
- Pre-validate: Number.isInteger(Number(v)) && Number(v) >= 0 && Number(v) <= 600.
Example fix
// before opencli twitter list-batch-add 123456789 --usernames alice --interval 5000 ArgumentError: Invalid interval: "5000". Expected an integer from 0 to 600. // after opencli twitter list-batch-add 123456789 --usernames alice --interval 5
Defensive patterns
Strategy: validation
Validate before calling
const n = raw === undefined || raw === '' ? 5 : Number(raw);
if (!Number.isInteger(n) || n < 0 || n > 600) {
throw new Error(`--interval must be an integer of seconds 0-600, got ${JSON.stringify(raw)}`);
} Type guard
function isValidInterval(v) {
const n = v === undefined || v === null || v === '' ? 5 : Number(v);
return Number.isInteger(n) && n >= 0 && n <= 600;
} Try / catch
try {
await runBatch(argv);
} catch (e) {
if (e instanceof ArgumentError && /Invalid interval/.test(e.message)) {
console.error(`${e.message} — interval is seconds, not ms; omit the flag for the 5s default.`);
return;
}
throw e;
} Prevention
- Remember the unit is seconds (0–600), not milliseconds.
- Omit --interval to accept the 5-second default.
- Use plain integers — no suffixes like '5s' or decimals.
- Convert ms→s explicitly in scripts before passing the value.
When it happens
Trigger: Passing --interval with a non-integer (2.5), a non-number ("fast"), a negative value (-1), or >600 (700); any of these fail Number.isInteger/range checks after Number() coercion (note Number('fast') is NaN).
Common situations: Unit confusion (thinking interval is in milliseconds and passing 5000); typo "5s" or "fast"; decimal values; empty-ish strings handled fine but 'none' is not; scripts interpolating a bad variable.
Understand the failure class
Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.
Related errors
- ${label} must be between ${min} and ${max}, got ${parsed}
- ${label} must be <= ${max}
- --${name} must be between ${min} and ${max}, got ${parsed}
- flomo memos --${name} must be between 1 and ${max}
- limit must be an integer between 1 and ${max}
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/4d73fe91cb23554a.
Report an issue: GitHub.