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

  1. Use --limit 50 or less per request.
  2. Paginate with the --cursor option to fetch more results across calls.
  3. 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

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


AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29). Data as JSON: /api/errors/66f67336137254a3. Report an issue: GitHub.