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
resolveBvid converts user input (URL, full link, or bare ID) into a canonical BV ID. When conversion fails the library wraps the underlying error in an ArgumentError echoing the original input, so the user sees what could not be parsed.
Source
Thrown at clis/bilibili/comment.js:48
],
columns: ['rpid', 'bvid', 'oid', 'message', 'url'],
func: async (page, kwargs) => {
if (!page) {
throw new CommandExecutionError('Browser session required for bilibili comment');
}
const message = String(kwargs.message ?? '').trim();
if (!message)
throw new ArgumentError('bilibili comment message cannot be empty');
// Write guard: posting is public and irreversible-ish, so require an explicit opt-in.
if (!kwargs.execute)
throw new ArgumentError('Refusing to post: pass --execute to actually publish this comment');
const parent = kwargs.parent != null ? readPositiveInteger(kwargs.parent, 'parent') : null;
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 (the reply API addresses videos by aid, as `oid`)
const view = await apiGet(page, '/x/web-interface/view', { params: { bvid } });
const viewData = requireOkPayload(view, 'view');
const oid = viewData?.aid;
if (!oid)
throw new CommandExecutionError(`Cannot resolve aid for bvid: ${bvid}`);
// Resolve @username mentions to uids. Bilibili only turns "@name" into a real
// mention — one that notifies the mentioned user — when the request carries
// at_name_to_mid; a plain-text "@name" is otherwise inert and notifies nobody.
/** @type {Record<string, number>} */
const atNameToMid = {};
for (const match of message.matchAll(/@([^\s@]+)/g)) {
const name = match[1];
if (name in atNameToMid)
continue;
try {
const mid = Number(await resolveUid(page, name));View on GitHub (pinned to 49907e53dc)
Solutions
- Pass the bare BV id (e.g. --bvid BV1xx411c7mD) or a canonical watch URL
- Read the wrapped error.message (second argument) to see the root cause
- Check network access to bilibili.com if the cause was a fetch failure
- Verify the video still exists (deleted videos fail resolution)
Example fix
// before cli bilibili comment --bvid "https://www.bilibili.com/video/BV1xx?spm_id_from=..." --message hi --execute // after cli bilibili comment --bvid BV1xx411c7mD --message hi --execute
Defensive patterns
Strategy: validation
Validate before calling
const m = String(bvidInput).match(/BV[0-9A-Za-z]{10}/);
if (!m) throw new Error(`Input does not contain a valid BV id: ${bvidInput}`); Type guard
const isBvid = (v) => typeof v === 'string' && /^BV[0-9A-Za-z]{10}$/.test(v.trim()); Try / catch
try { await commentCmd(); } catch (e) { if (String(e.message).includes('Cannot resolve Bilibili BV ID')) { console.error('Use a bare BV id, e.g. --bvid BV1xx411c7mD'); } else throw e; } Prevention
- Pass canonical BV ids rather than decorated URLs
- Check the video still exists before commenting
- Read the wrapped cause in the second error argument
- Handle av-id vs bvid distinctions
When it happens
Trigger: --bvid contains a malformed ID, an unsupported URL format (e.g. a short link the resolver doesn't handle), or the underlying fetch inside resolveBvid fails (network/HTTP error) and is caught and rethrown here.
Common situations: Passing a full video page URL with query params the resolver mishandles; typo in the BV id; passing an av-number where a BV is expected; network failure during resolution.
Related errors
- ${label} must be a non-negative integer, got ${JSON.stringif
- limit must be a positive integer
- archive wayback timestamp must be YYYY[MM[DD[hh[mm[ss]]]]] o
- archive wayback url cannot be empty
- bilibili comment ${label} must be a positive integer
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/86d8c298fd595df5.
Report an issue: GitHub.