jackwener/OpenCLI · error · ArgumentError
--page is too large: ${value}
Error message
--page is too large: ${value} What it means
Final guard of parsePageArg: a string passing the /^[1-9]\d*$/ regex can still exceed Number.MAX_SAFE_INTEGER when converted with Number(), e.g. a 30-digit page number. In that case the function throws '--page is too large: <value>' rather than silently losing precision.
Source
Thrown at clis/bilibili/utils.js:95
});
}
/**
* 解析 --page 选集序号(分P / 视频选集)。
* 缺省/空串 → null(不下钻,保持整集默认 P1 旧行为)。
* 非正十进制整数 → 抛 ArgumentError(参数错误,不静默吞)。
*/
export function parsePageArg(value) {
if (value == null || value === '') return null;
if (typeof value === 'number') {
if (Number.isSafeInteger(value) && value >= 1) return value;
throw new ArgumentError(`--page must be a positive decimal integer, got: ${value}`);
}
if (typeof value !== 'string' || !/^[1-9]\d*$/.test(value)) {
throw new ArgumentError(`--page must be a positive decimal integer, got: ${String(value)}`);
}
const n = Number(value);
if (!Number.isSafeInteger(n)) {
throw new ArgumentError(`--page is too large: ${value}`);
}
return n;
}
function readApiPositiveInteger(value, label) {
if (typeof value === 'number' && Number.isSafeInteger(value) && value >= 1) {
return value;
}
if (typeof value === 'string' && /^[1-9]\d*$/.test(value)) {
const n = Number(value);
if (Number.isSafeInteger(n)) return n;
}
throw new CommandExecutionError(`Bilibili view API returned a malformed ${label}`);
}
/**
* 从 view API 的 data.pages 数组取第 N 集(1-based)。
* page/cid 都以 view API 的 pages[] 为 source-of-truth;缺失、重复或畸形都 fail closed。View on GitHub (pinned to 49907e53dc)
Solutions
- Pass a realistic page number (actual video part counts are small — typically < 1000)
- Check you didn't paste a uid/BVID into --page
- Validate length upstream: value.length <= 16 before calling
- Use BigInt-free logic: if (value.length > 15) reject before Number()
Example fix
// before
parsePageArg('123456789012345678901234567890');
// after
parsePageArg('3'); Defensive patterns
Strategy: validation
Validate before calling
function isReasonablePage(v) {
const s = String(v ?? '').trim();
return /^[1-9]\d*$/.test(s) && s.length <= 9; // well within MAX_SAFE_INTEGER and real part counts
} Type guard
function isBoundedPageString(v) {
if (typeof v !== 'string' || !/^[1-9]\d*$/.test(v)) return false;
const n = Number(v);
return Number.isSafeInteger(n) && n <= 100000;
} Try / catch
try {
const page = parsePageArg(value);
} catch (err) {
if (err instanceof ArgumentError && /too large/.test(err.message)) {
console.error(`--page '${value}' overflows; did you paste a uid? Using default page.`);
const page = null;
} else throw err;
} Prevention
- Bound-check string length (<= 9 digits for realistic part counts) before calling
- Don't pass uids or BVID digit strings into --page
- Sanity-check generated page numbers in loops against the video's actual part count
- If very large numbers are legitimate upstream, convert/validate with BigInt before calling this API
When it happens
Trigger: Calling parsePageArg('99999999999999999999') — digits-only string whose numeric value is greater than 2^53-1.
Common situations: Pasting a uid or video id into the --page flag by mistake; a script concatenating numbers instead of adding them; fat-fingering a very long digit string.
Related errors
- bilibili unfollow target must be a valid space.bilibili.com/
- --page must be a positive decimal integer, got: ${value}
- --page must be a positive decimal integer, got: ${String(val
- archive snapshots url cannot be empty
- archive snapshots limit must be a positive integer
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/9ad12dcea2fce182.
Report an issue: GitHub.