jackwener/OpenCLI · error · ArgumentError
${label} must be <= ${maxValue}
Error message
${label} must be <= ${maxValue} What it means
requirePositiveInt also enforces an upper bound: if the parsed value exceeds the caller-supplied maxValue it throws ArgumentError with this message. For creator-videos the server page size caps at 50 (SERVER_PAGE_MAX), so a limit above that cannot be satisfied by a single server page.
Source
Thrown at clis/tiktok/creator-videos.js:23
CommandExecutionError,
EmptyResultError,
getErrorMessage,
} from '@jackwener/opencli/errors';
const STUDIO_CONTENT_URL = 'https://www.tiktok.com/tiktokstudio/content';
const ITEM_LIST_API_PATH = '/tiktok/creator/manage/item_list/v1/';
const DEFAULT_LIMIT = 20;
const MAX_LIMIT = 250;
const SERVER_PAGE_MAX = 50;
function requirePositiveInt(value, label, defaultValue, maxValue) {
const raw = value ?? defaultValue;
const parsed = Number(raw);
if (!Number.isInteger(parsed) || parsed <= 0) {
throw new ArgumentError(`${label} must be a positive integer`, `Example: opencli tiktok creator-videos --${label} ${defaultValue}`);
}
if (parsed > maxValue) {
throw new ArgumentError(`${label} must be <= ${maxValue}`, `Example: opencli tiktok creator-videos --${label} ${maxValue}`);
}
return parsed;
}
function requireCursor(value) {
const raw = value ?? '0';
const text = String(raw).trim();
if (!/^\d+$/.test(text)) {
throw new ArgumentError('cursor must be a non-negative integer string', 'Example: opencli tiktok creator-videos --cursor 0');
}
const cursor = Number(text);
if (!Number.isSafeInteger(cursor)) {
throw new ArgumentError('cursor must be a safe integer', 'Example: opencli tiktok creator-videos --cursor 0');
}
return cursor;
}
function buildItemListRequest(cursor, size) {View on GitHub (pinned to 49907e53dc)
Solutions
- Use --limit 50 or less per request.
- Paginate with the --cursor option to fetch more results across calls.
- If a bulk export is needed, loop in a script: request page, take nextCursor, repeat until exhausted.
Example fix
// before opencli tiktok creator-videos --limit 100 // after opencli tiktok creator-videos --limit 50 --cursor 0 # then repeat with --cursor <nextCursor>
Defensive patterns
Strategy: validation
Validate before calling
const SERVER_PAGE_MAX = 50;
const limit = Math.min(Number(process.env.TT_LIMIT ?? 20), SERVER_PAGE_MAX);
if (!Number.isInteger(limit) || limit <= 0) throw new Error('limit must be a positive integer <= 50'); Type guard
const isValidLimit = (v, max = 50) => Number.isInteger(Number(v)) && Number(v) > 0 && Number(v) <= max;
Try / catch
try {
await run(['tiktok', 'creator-videos', '--limit', String(limit)]);
} catch (e) {
if (String(e.message).includes('must be <=')) {
console.error('Clamping limit to server max of 50 and retrying');
await run(['tiktok', 'creator-videos', '--limit', '50', '--cursor', '0']);
} else throw e;
} Prevention
- Clamp requested page sizes to the server maximum (50) before invoking.
- Use cursor pagination instead of oversized limits for bulk fetches.
- Centralize the max-page-size constant in your scripts.
When it happens
Trigger: Running `opencli tiktok creator-videos --limit 100` (or any value > 50) — parsed value is a positive integer but exceeds maxValue.
Common situations: Developers assuming the CLI will loop pages internally and pass a large limit; copying limits from other tools with higher caps; trying to fetch an entire catalog in one call.
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
- cursor must be a non-negative integer string
- --page must be a positive integer (got ${raw})
- --offset must be a multiple of 10 for DuckDuckGo HTML pagina
- juejin ${label} must be <= ${maxValue}
- openreview ${label} must be a positive integer
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/66f67336137254a3.
Report an issue: GitHub.