{"record":{"id":"68deeb334d496ef8","repo":"DIYgod/RSSHub","slug":"response-message-error-code-response-code-68deeb","errorCode":null,"errorMessage":"response.message ?? `Error code ${response.code}`","messagePattern":"response\\.message \\?\\? `Error code (.+?)`","errorType":"exception","errorClass":null,"httpStatus":503,"severity":"error","filePath":"lib/routes/bilibili/message-reply.ts","lineNumber":115,"sourceCode":"    const cookie = config.bilibili.cookies[uid];\n    if (cookie === undefined) {\n        throw new ConfigNotFoundError('缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值');\n    }\n\n    const response = await ofetch<ReplyResponse>('https://api.bilibili.com/x/msgfeed/reply', {\n        query: {\n            platform: 'web',\n            build: 0,\n            mobi_app: 'web',\n        },\n        headers: {\n            Referer: 'https://message.bilibili.com/',\n            Cookie: cookie,\n        },\n    });\n\n    if (response.code !== 0) {\n        throw new Error(response.message ?? `Error code ${response.code}`);\n    }\n\n    const items: DataItem[] = (response.data.items || []).map((item) => {\n        const replyUser = item.user;\n        const replyItem = item.item;\n        const sourceContent = replyItem.source_content;\n        const targetContent = replyItem.target_reply_content;\n        const rootContent = replyItem.root_reply_content;\n\n        let description = `<p><strong>${replyUser.nickname}</strong> 回复了你：</p>`;\n        description += `<blockquote>${sourceContent}</blockquote>`;\n\n        if (targetContent) {\n            description += `<p>你的评论：</p><blockquote>${targetContent}</blockquote>`;\n        } else if (rootContent) {\n            description += `<p>你的评论：</p><blockquote>${rootContent}</blockquote>`;\n        }\n","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/bilibili/message-reply.ts#L97-L133","documentation":"Raised by the message-reply route when the call to https://api.bilibili.com/x/msgfeed/reply returns a non-zero business code despite an HTTP 200. The Cookie was present but Bilibili rejected the request at the application layer; the upstream `message` (or a fallback 'Error code N') is re-thrown as a plain Error. Typical of expired/invalid sessions or anti-crawler intervention.","triggerScenarios":"GET /bilibili/message/reply/:uid where the BILIBILI_COOKIE_{uid} is expired (code -101), triggers risk control (-352/-799), or the cookie's account does not match the path uid.","commonSituations":"SESSDATA rotated by Bilibili after a security event; cookie copied without bili_jct/DedeUserID; account flagged by risk control from aggressive RSS polling; upstream API contract change.","solutions":["Re-login to bilibili.com and replace BILIBILI_COOKIE_{uid} with the fresh full Cookie (SESSDATA + bili_jct + DedeUserID).","Inspect the code in the message: -101 invalid session, -352/-799 risk control (slow down / rotate account), -403 permission.","Lower your RSS reader poll interval (>= 10 min) and avoid running multiple RSSHub instances against the same account.","Confirm DedeUserID inside the cookie equals the uid in the path."],"exampleFix":"// before\nif (response.code !== 0) {\n    throw new Error(response.message ?? `Error code ${response.code}`);\n}\n\n// after\nif (response.code !== 0) {\n    if (response.code === -101) {\n        throw new ConfigNotFoundError(`Cookie for uid ${uid} expired (code -101). Update BILIBILI_COOKIE_${uid}.`);\n    }\n    throw new Error(response.message ?? `Error code ${response.code}`);\n}","handlingStrategy":"retry","validationCode":"import ofetch from '@/utils/ofetch';\nimport { config } from '@/config';\n\nasync function cookieStillValid(uid: string): Promise<boolean> {\n  const cookie = config.bilibili.cookies[uid];\n  if (!cookie) return false;\n  const r = await ofetch<{ code: number }>('https://api.bilibili.com/x/web-interface/nav', { headers: { Cookie: cookie } });\n  return r.code === 0;\n}","typeGuard":"interface BiliEnv<T> { code: number; message?: string; data?: T }\nfunction isBiliOk<T>(r: BiliEnv<T>): r is BiliEnv<T> & { code: 0; data: T } { return r.code === 0; }","tryCatchPattern":"try {\n  if (response.code !== 0) throw new Error(response.message ?? `Error code ${response.code}`);\n} catch (e) {\n  const m = e instanceof Error ? e.message : '';\n  if (m.includes('-101')) throw new Error(`Refresh BILIBILI_COOKIE_${uid} (session expired)`);\n  if (m.includes('-352') || m.includes('-799')) { await sleepThenRetry(); }\n  throw e;\n}","preventionTips":["Health-check each cookie via /x/web-interface/nav periodically and alert on -101.","Cache reply-feed results for several minutes to reduce upstream load.","Keep poll intervals >= 10 minutes; never run two RSSHub instances against one account.","Verify DedeUserID in the cookie equals the path uid."],"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"}