jackwener/OpenCLI · error · ArgumentError
bilibili comments parent must be a positive integer rpid
Error message
bilibili comments parent must be a positive integer rpid
What it means
ArgumentError thrown by parseParent when the --parent option (a Bilibili comment rpid used to fetch nested 'floor' replies) is not a positive integer. Null/undefined is allowed (means 'no parent'), but any provided value must coerce via Number() to an integer > 0.
Source
Thrown at clis/bilibili/comments.js:31
return code === -101 || code === -403 || /登录|账号|权限|forbidden|permission|login/i.test(String(message ?? ''));
}
function parseLimit(value) {
const raw = value == null ? 20 : value;
const limit = Number(raw);
if (!Number.isInteger(limit) || limit <= 0 || limit > MAX_LIMIT) {
throw new ArgumentError(`bilibili comments limit must be an integer between 1 and ${MAX_LIMIT}`);
}
return limit;
}
function parseParent(value) {
if (value == null) {
return null;
}
const parent = Number(value);
if (!Number.isInteger(parent) || parent <= 0) {
throw new ArgumentError('bilibili comments parent must be a positive integer rpid');
}
return parent;
}
function requireOkPayload(payload, label) {
if (!payload || typeof payload !== 'object' || Array.isArray(payload) || !Object.hasOwn(payload, 'code')) {
throw new CommandExecutionError(`Bilibili ${label} API returned a malformed payload`);
}
if (payload.code !== 0) {
const message = payload.message ?? 'unknown error';
if (isAuthLikeBilibiliError(payload.code, message)) {
throw new AuthRequiredError('bilibili.com', `Bilibili ${label} API requires login or permission: ${message} (${payload.code})`);
}
throw new CommandExecutionError(`Bilibili ${label} API failed: ${message} (${payload.code})`);
}
return payload.data;
}
View on GitHub (pinned to 49907e53dc)
Solutions
- Pass the full numeric rpid exactly as shown in the comments table (rank/rpid column)
- Verify the rpid is a positive integer string before passing it
- Keep rpid as a string in scripts to avoid precision loss, and only pass digits
Example fix
// before bilibili comments BV1WtAGzYEBm --parent 0 // after bilibili comments BV1WtAGzYEBm --parent 3498271543
Defensive patterns
Strategy: validation
Validate before calling
function isValidRpid(v) { return v != null && Number.isInteger(Number(v)) && Number(v) > 0; }
if (parent != null && !isValidRpid(parent)) throw new Error('parent must be a positive integer rpid'); Type guard
function isPositiveInt(v) { const n = Number(v); return Number.isInteger(n) && n > 0; } Try / catch
try { ... } catch (e) { if (/parent must be a positive integer/.test(e.message)) { console.error('bad --parent rpid: ' + parent); process.exitCode = 2; } else throw e; } Prevention
- Copy rpid verbatim from the comments table output
- Store rpid as a string to avoid JS number precision loss on large ids
- Validate with /^\d+$/ before passing --parent
When it happens
Trigger: Calling `bilibili comments <bvid> --parent abc`, `--parent 0`, `--parent -1`, or `--parent 12.5`; passing an rpid that was truncated or mangled (e.g. lost precision as a JS number elsewhere).
Common situations: Copy-pasting a partial rpid; treating rpid as a float; shell quoting issues that split the rpid; rpid sourced from JSON parsed with numbers losing precision for very large ids.
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
- bilibili comments limit must be an integer between 1 and ${M
- boss ${name} must be <= ${max}
- ${label} must be a positive integer
- prompt is required
- pubmed ${label} must be a positive integer
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/e02271b35a140bf9.
Report an issue: GitHub.