jackwener/OpenCLI · error · ArgumentError
Bilibili summary URL must use http or https
Error message
Bilibili summary URL must use http or https
What it means
If the bvid input parses as a URL, readBvid only accepts http: or https: schemes. Any other scheme (ftp:, file:, javascript:, ws:, etc.) is rejected with this ArgumentError because the resolver only knows how to fetch over HTTP(S). This is a scheme whitelist check on already-parsed URLs.
Source
Thrown at clis/bilibili/summary.js:38
}
async function readBvid(raw) {
const input = String(raw ?? '').trim();
if (!input) {
throw new ArgumentError('bilibili summary bvid cannot be empty', 'Pass a BV ID, Bilibili video URL, or b23.tv short link.');
}
if (BVID_RE.test(input)) {
return input;
}
let parsed = null;
try {
parsed = new URL(input);
} catch {
// Bare b23.tv short codes are accepted by the shared resolver.
}
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));
}
}View on GitHub (pinned to 49907e53dc)
Solutions
- Use an https:// URL, e.g. https://www.bilibili.com/video/BV1xx411c7mD.
- Or skip the URL entirely and pass the bare BV ID (BV...).
- If the input is generated by your code, fix the scheme construction (http/https only).
Example fix
// before
const input = `ftp://www.bilibili.com/video/${bvid}`;
// after
const input = `https://www.bilibili.com/video/${bvid}`; Defensive patterns
Strategy: validation
Validate before calling
let parsed;
try { parsed = new URL(input); } catch { parsed = null; }
if (parsed && parsed.protocol !== 'https:' && parsed.protocol !== 'http:') {
throw new Error(`Unsupported protocol ${parsed.protocol}; use http(s)`);
} Type guard
function isHttpUrl(s) {
try { const u = new URL(s); return u.protocol === 'https:' || u.protocol === 'http:'; }
catch { return false; }
} Try / catch
try {
await summaryCommand(input);
} catch (e) {
if (/must use http or https/.test(e.message)) {
const fixed = input.replace(/^\w+:/, 'https:');
await summaryCommand(fixed);
} else throw e;
} Prevention
- Normalize any programmatically built Bilibili links to https://.
- Never paste file/ftp/magnet URIs as video identifiers.
- Prefer passing the bare BV id when you already have it.
When it happens
Trigger: Passing a URL-like string whose protocol is not http/https, e.g. `bvid('ftp://bilibili.com/video/BV1xx411c7mD')` or `bvid('file:///tmp/BV1xx411c7mD')`; `new URL()` succeeds, the protocol check at summary.js:37-39 fails.
Common situations: Copy-pasting a link from a non-browser tool that emits other schemes; constructing URLs programmatically with a wrong base scheme; accidentally passing a magnet/file URI.
Related errors
- Bilibili summary URL must contain a BV video id
- Bilibili summary URL must be a bilibili.com or b23.tv URL
- url must be on h5.xet.citv.cn or a shop subdomain (got ${par
- Unknown 12306 station telecode "${trimmed}"
- Unknown 12306 station "${trimmed}"
AI-assisted analysis of jackwener/OpenCLI@49907e53dc (2026-08-29).
Data as JSON: /api/errors/0149a56e3c4d3093.
Report an issue: GitHub.