jackwener/OpenCLI · error · ArgumentError
Cannot resolve Bilibili BV ID from input: ${String(kwargs.bv
Error message
Cannot resolve Bilibili BV ID from input: ${String(kwargs.bvid ?? '')} What it means
An ArgumentError wrapping a failure from resolveBvid: the CLI could not turn the user-supplied input (kwargs.bvid) into a valid Bilibili BV ID. The original error message is attached as the cause, and the raw input is echoed in the message (empty string when undefined).
Source
Thrown at clis/bilibili/comments.js:131
{ name: 'limit', type: 'int', default: 20, help: 'Number of comments (max 50)' },
],
columns: ['rank', 'rpid', 'author', 'text', 'likes', 'replies', 'time'],
func: async (page, kwargs) => {
if (!page) {
throw new CommandExecutionError('Browser session required for bilibili comments');
}
const limit = parseLimit(kwargs.limit);
const parent = parseParent(kwargs.parent);
const top = kwargs.top === true;
if (top && parent != null) {
throw new ArgumentError('bilibili comments --top cannot be combined with --parent (pinned comments only exist at the top level)');
}
let bvid;
try {
bvid = await resolveBvid(kwargs.bvid);
}
catch (error) {
throw new ArgumentError(`Cannot resolve Bilibili BV ID from input: ${String(kwargs.bvid ?? '')}`, error instanceof Error ? error.message : String(error));
}
// Resolve bvid → aid (required by reply API)
const view = await apiGet(page, '/x/web-interface/view', { params: { bvid } });
const viewData = requireOkPayload(view, 'view');
const aid = viewData?.aid;
if (!aid)
throw new CommandExecutionError(`Cannot resolve aid for bvid: ${bvid}`);
const payload = parent != null
? await apiGet(page, '/x/v2/reply/reply', {
params: { oid: aid, type: 1, root: parent, pn: 1, ps: limit },
})
: await apiGet(page, '/x/v2/reply/main', {
params: { oid: aid, type: 1, mode: 3, ps: top ? 1 : limit },
signed: true,
});
const label = parent != null ? 'reply thread' : 'reply main';
const data = requireOkPayload(payload, label);
const replies = topView on GitHub (pinned to 49907e53dc)
Solutions
- Pass a canonical BV ID like BV1WtAGzYEBm as the positional argument
- Check the cause message for the resolver's specific complaint (bad format vs failed network resolution)
- Resolve the URL to a BV ID yourself before invoking if using short links
- Verify no stray whitespace/characters were copied into the argument
Example fix
// before bilibili comments "https://b23.tv/abc123" bilibili comments av170001 // after bilibili comments BV1WtAGzYEBm
Defensive patterns
Strategy: validation
Validate before calling
const BV_RE = /^BV[0-9A-Za-z]{10}$/;
if (!BV_RE.test(String(bvid ?? '').trim())) {
throw new Error(`input is not a canonical BV ID: ${bvid}`);
} Type guard
function isBvid(input) {
return typeof input === 'string' && /^BV[0-9A-Za-z]{10}$/.test(input.trim());
} Try / catch
try {
const rows = await bilibiliComments(input);
} catch (err) {
if (err instanceof ArgumentError && /Cannot resolve Bilibili BV ID/.test(err.message)) {
// normalize the URL/input to a BV ID and retry
} else throw err;
} Prevention
- Normalize short links (b23.tv) and URLs to a BV ID before calling
- Trim whitespace and avoid copy-paste artifacts
- Pass only canonical BV IDs like BV1WtAGzYEBm
- Read the cause message to distinguish format vs network failures
When it happens
Trigger: Passing something that resolveBvid cannot parse — a malformed BV ID, a full URL variant it doesn't recognize, an AV number when only BV is accepted, or an empty/undefined bvid.
Common situations: Copy-pasting a short link (b23.tv) or mobile URL that the resolver doesn't handle; typos in the BV ID; passing a title or search term instead of an ID; forgetting the positional argument.
Related errors
- Unknown 12306 station telecode "${trimmed}"
- Unknown 12306 station "${trimmed}"
- date must be YYYY-MM-DD, got "${value}"
- date "${value}" is not a real calendar date
- limit must be a positive integer (1-${max})
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/b6b315789be31cd9.
Report an issue: GitHub.