{"record":{"id":"41b8c3fb55743a54","repo":"DIYgod/RSSHub","slug":"it-looks-like-something-went-wrong-when-querying-t","errorCode":null,"errorMessage":"It looks like something went wrong when querying the Bilibili API: code = ${data.code}, message = ${data.message}","messagePattern":"It looks like something went wrong when querying the Bilibili API: code = (.+?), message = (.+?)","errorType":"exception","errorClass":null,"httpStatus":503,"severity":"error","filePath":"lib/routes/bilibili/user-bangumi.ts","lineNumber":45,"sourceCode":"    handler,\n};\n\nasync function handler(ctx) {\n    const uid = ctx.req.param('uid');\n    const type = Number(ctx.req.param('type') || 1);\n    const type_name = ((t) => ['', 'bangumi', 'cinema'][t])(type);\n    const name = await cache.getUsernameFromUID(uid);\n\n    const response = await got({\n        method: 'get',\n        url: `https://api.bilibili.com/x/space/bangumi/follow/list?type=${type}&follow_status=0&pn=1&ps=15&vmid=${uid}`,\n        headers: {\n            Referer: `https://space.bilibili.com/${uid}/${type_name}`,\n        },\n    });\n    const data = response.data;\n    if (data.code !== 0) {\n        throw new Error(`It looks like something went wrong when querying the Bilibili API: code = ${data.code}, message = ${data.message}`);\n    }\n\n    return {\n        title: `${name} 的追番列表`,\n        link: `https://space.bilibili.com/${uid}/${type_name}`,\n        description: `${name} 的追番列表`,\n        item:\n            data.data &&\n            data.data.list &&\n            data.data.list.map((item) => ({\n                title: `[${item.new_ep.index_show}]${item.title}`,\n                description: `${item.evaluate}<br><img src=\"${item.cover}\">`,\n                pubDate: new Date(item.new_ep.pub_time ?? Date.now()).toUTCString(),\n                link: 'https://www.bilibili.com/bangumi/play/' + (item.new_ep.id ? `ep${item.new_ep.id}` : `ss${item.season_id}`),\n            })),\n    };\n}\n","sourceCodeStart":27,"sourceCodeEnd":63,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/bilibili/user-bangumi.ts#L27-L63","documentation":"Thrown by /bilibili/user/bangumi/:uid when the user's bangumi follow-list API (https://api.bilibili.com/x/space/bangumi/follow/list) returns a non-zero business code. The handler re-throws the upstream code and message verbatim as a plain Error. The endpoint needs the requester's own session for private follow lists and a valid Referer for public ones; non-zero codes commonly reflect visibility/permission or anti-crawler states.","triggerScenarios":"GET /bilibili/user/bangumi/:uid where the target user hid their follow list (code -403), the uid does not exist, or Bilibili returned risk-control code -352 because the call lacks a Cookie/wbi signature. The route uses got() with only a Referer header and no Cookie, so it is more exposed to anti-crawler blocks.","commonSituations":"Target user set their bangumi list to private; RSSHub IP flagged by anti-crawler; bilibili now requires wbi signing on this endpoint which the route does not perform; uid typo.","solutions":["Confirm the uid is valid and the user's 番剧 follow list is public on space.bilibili.com/{uid}/bangumi.","Set a BILIBILI_COOKIE_* so the request is authenticated (though this route currently does not forward one — patching it to send Cookie + wbi signature is the robust fix).","Retry after a cooldown if the code looks like risk control (-352/-799).","Decode the code/message in the error text to pinpoint permission (-403) vs anti-crawler (-352) vs not-found."],"exampleFix":"// before\nconst response = await got({\n    url: `https://api.bilibili.com/x/space/bangumi/follow/list?type=${type}&...&vmid=${uid}`,\n    headers: { Referer: `https://space.bilibili.com/${uid}/${type_name}` },\n});\nif (data.code !== 0) {\n    throw new Error(`It looks like something went wrong when querying the Bilibili API: code = ${data.code}, message = ${data.message}`);\n}\n\n// after (authenticate + classify)\nconst cookie = await cache.getCookie();\nconst response = await got({\n    url: `https://api.bilibili.com/x/space/bangumi/follow/list?type=${type}&...&vmid=${uid}`,\n    headers: { Referer: `https://space.bilibili.com/${uid}/${type_name}`, Cookie: cookie },\n});\nif (data.code !== 0) {\n    if (data.code === -403) {\n        throw new Error(`User ${uid}'s bangumi list is private`);\n    }\n    throw new Error(`Bilibili API error: code = ${data.code}, message = ${data.message}`);\n}","handlingStrategy":"retry","validationCode":"// Confirm the uid exists and the bangumi list is public before subscribing.\nimport got from '@/utils/got';\nasync function bangumiListAccessible(uid: string, type: number) {\n  const { data } = await got(`https://api.bilibili.com/x/space/bangumi/follow/list`, {\n    searchParams: { type, follow_status: 0, pn: 1, ps: 1, vmid: uid },\n    headers: { Referer: `https://space.bilibili.com/${uid}/bangumi` },\n  });\n  return data.code === 0;\n}","typeGuard":"interface BangumiEnv<T> { code: number; message?: string; data?: { list?: T[] } }\nfunction isBangumiOk<T>(r: BangumiEnv<T>): r is BangumiEnv<T> & { code: 0 } { return r.code === 0; }","tryCatchPattern":"try {\n  if (data.code !== 0) throw new Error(`code=${data.code} message=${data.message}`);\n} catch (e) {\n  const m = e instanceof Error ? e.message : '';\n  if (m.includes('-403')) throw new Error(`User ${uid}'s bangumi list is private`);\n  if (m.includes('-352') || m.includes('-799')) await backoffRetry();\n  throw e;\n}","preventionTips":["Patch the route to forward a Cookie (cache.getCookie) so private/anti-crawler states don't reject the call.","Verify the target user has not hidden their 番剧 list before subscribing.","Cache the follow-list result for several minutes to lower upstream pressure.","If you maintain the instance, consider adding wbi signing consistent with the video route."],"tags":["bilibili","api-error","authentication","anti-crawler","rsshub"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}