{"record":{"id":"bb15831758a119d5","repo":"jackwener/OpenCLI","slug":"cannot-resolve-bilibili-bv-id-from-input-input","errorCode":null,"errorMessage":"Cannot resolve Bilibili BV ID from input: ${input}","messagePattern":"Cannot resolve Bilibili BV ID from input: (.+?)","errorType":"validation","errorClass":"ArgumentError","httpStatus":null,"severity":"error","filePath":"clis/bilibili/summary.js","lineNumber":54,"sourceCode":"    if (parsed) {\n        if (parsed.protocol !== 'https:' && parsed.protocol !== 'http:') {\n            throw new ArgumentError('Bilibili summary URL must use http or https');\n        }\n        if (BILIBILI_HOST_RE.test(parsed.hostname)) {\n            const match = parsed.pathname.match(/\\/(?:video|bangumi\\/play)\\/(BV[A-Za-z0-9]+)/i);\n            if (!match) {\n                throw new ArgumentError('Bilibili summary URL must contain a BV video id');\n            }\n            return match[1];\n        }\n        if (!B23_HOST_RE.test(parsed.hostname)) {\n            throw new ArgumentError('Bilibili summary URL must be a bilibili.com or b23.tv URL');\n        }\n    }\n    try {\n        return await resolveBvid(input);\n    } catch (error) {\n        throw new ArgumentError(`Cannot resolve Bilibili BV ID from input: ${input}`, error instanceof Error ? error.message : String(error));\n    }\n}\n\nfunction requireOkPayload(payload, label) {\n    if (!payload || typeof payload !== 'object' || Array.isArray(payload)) {\n        throw new CommandExecutionError(`Bilibili ${label} API returned a malformed payload`);\n    }\n    if (payload.code !== 0) {\n        const message = payload.message ?? 'unknown error';\n        if (payload.code === -101 || payload.code === -403 || /登录|权限|forbidden|permission|login/i.test(String(message))) {\n            throw new AuthRequiredError('bilibili.com', `Bilibili ${label} API requires login or permission: ${message} (${payload.code})`);\n        }\n        throw new CommandExecutionError(`Bilibili ${label} API failed: ${message} (${payload.code})`);\n    }\n    return payload.data;\n}\n\nfunction readModelResult(data, bvid) {","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/jackwener/OpenCLI/blob/49907e53dc3ade5c223ff0c4c2c2785687cec4e6/clis/bilibili/summary.js#L36-L72","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","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."],"exampleFix":"// before\nawait summaryCommand('https://b23.tv/expired123');\n// after\nawait summaryCommand('BV1xx411c7mD'); // skip short-link resolution","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await summaryCommand(shortLink);\n} catch (e) {\n  if (/Cannot resolve Bilibili BV ID/.test(e.message)) {\n    console.error('Short link failed:', e.cause ?? e.message);\n    // fallback: ask for the full URL or BV id\n  } else throw e;\n}","preventionTips":["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."],"tags":["url-resolution","network","short-link","argument-error"],"backgroundTag":"short-link-resolution-failed","analyzedSha":"49907e53dc3ade5c223ff0c4c2c2785687cec4e6","analyzedAt":"2026-08-29T08:14:47.543Z","schemaVersion":2},"datasetVersion":"2026-08-29T12:17:43.993Z"}