jackwener/OpenCLI · error · ArgumentError
Cannot resolve Bilibili BV ID from input: ${input}
Error message
Cannot resolve Bilibili BV ID from input: ${input} What it means
When the input is not directly extractable (not a bare BV id, not a parseable bilibili URL), readBvid delegates to the shared resolveBvid() helper — typically for b23.tv short links that redirect to the real video page. If resolution fails for any reason, the original error is wrapped in this ArgumentError with the failing input and the underlying message as the cause.
Source
Thrown at clis/bilibili/summary.js:54
if (parsed) {
if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') {
throw new ArgumentError('Bilibili summary URL must use http or https');
}
if (BILIBILI_HOST_RE.test(parsed.hostname)) {
const match = parsed.pathname.match(/\/(?:video|bangumi\/play)\/(BV[A-Za-z0-9]+)/i);
if (!match) {
throw new ArgumentError('Bilibili summary URL must contain a BV video id');
}
return match[1];
}
if (!B23_HOST_RE.test(parsed.hostname)) {
throw new ArgumentError('Bilibili summary URL must be a bilibili.com or b23.tv URL');
}
}
try {
return await resolveBvid(input);
} catch (error) {
throw new ArgumentError(`Cannot resolve Bilibili BV ID from input: ${input}`, error instanceof Error ? error.message : String(error));
}
}
function requireOkPayload(payload, label) {
if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {
throw new CommandExecutionError(`Bilibili ${label} API returned a malformed payload`);
}
if (payload.code !== 0) {
const message = payload.message ?? 'unknown error';
if (payload.code === -101 || payload.code === -403 || /登录|权限|forbidden|permission|login/i.test(String(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;
}
function readModelResult(data, bvid) {View on GitHub (pinned to 49907e53dc)
Solutions
- Open the short link in a browser to confirm it still resolves to a video, then copy the full bilibili.com URL or BV id.
- Check network connectivity/proxy settings that could block the redirect fetch.
- Pass the bare BV ID directly to skip resolution entirely.
- Inspect the wrapped cause message for the underlying HTTP error.
Example fix
// before
await summaryCommand('https://b23.tv/expired123');
// after
await summaryCommand('BV1xx411c7mD'); // skip short-link resolution Defensive patterns
Strategy: try-catch
Try / catch
try {
await summaryCommand(shortLink);
} catch (e) {
if (/Cannot resolve Bilibili BV ID/.test(e.message)) {
console.error('Short link failed:', e.cause ?? e.message);
// fallback: ask for the full URL or BV id
} else throw e;
} Prevention
- Prefer full bilibili.com URLs or bare BV ids over b23.tv short links.
- Short links expire — re-generate them if resolution fails.
- Ensure outbound HTTPS works (proxies, DNS) so the redirect fetch can succeed.
- Inspect the wrapped cause message to distinguish network vs. dead-link failures.
When it happens
Trigger: Passing an expired or deleted b23.tv short link; network failure/DNS error while following the redirect; the short link redirects to a non-video page so no BV id can be extracted; resolveBvid gets a non-200 or non-HTML response.
Common situations: Sharing short links that have expired or been revoked; offline or firewalled environments where the redirect fetch fails; b23.tv links that lead to login/bangumi pages without a BV id in the final URL.
Related errors
- 12306 queryByTrainNo returned HTTP ${resp.status}
- 12306 queryByTrainNo returned non-JSON body
- 12306 ${endpoint} returned non-JSON body
- 12306 ${endpoint} returned an unexpected payload shape
- 12306 rejected every known query endpoint name (${QUERY_ENDP
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/bb15831758a119d5.
Report an issue: GitHub.