{"record":{"id":"bd580e235d3afc76","repo":"DIYgod/RSSHub","slug":"got-error-code-data-code-while-fetching-data","errorCode":null,"errorMessage":"Got error code ${data.code} while fetching: ${data.message}","messagePattern":"Got error code (.+?) while fetching: (.+?)","errorType":"exception","errorClass":null,"httpStatus":503,"severity":"error","filePath":"lib/routes/bilibili/followings-video.ts","lineNumber":64,"sourceCode":"    if (cookie === undefined) {\n        throw new ConfigNotFoundError('缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值');\n    }\n\n    const response = await got({\n        method: 'get',\n        url: `https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/dynamic_new?uid=${uid}&type=8`,\n        headers: {\n            Referer: `https://space.bilibili.com/${uid}/`,\n            Cookie: cookie,\n        },\n    });\n    const data = response.data;\n    if (data.code) {\n        logger.error(JSON.stringify(data));\n        if (data.code === -6 || data.code === 4_100_000) {\n            throw new ConfigNotFoundError('对应 uid 的 Bilibili 用户的 Cookie 已过期');\n        }\n        throw new Error(`Got error code ${data.code} while fetching: ${data.message}`);\n    }\n    const cards = data.data.cards;\n\n    const out = cards.map((card) => {\n        const card_data = JSON.parse(card.card);\n\n        return {\n            title: card_data.title,\n            description: utils.renderUGCDescription(embed, card_data.pic, card_data.desc, card_data.aid, undefined, card.desc.bvid),\n            pubDate: new Date(card_data.pubdate * 1000).toUTCString(),\n            link: card_data.pubdate > utils.bvidTime && card.desc.bvid ? `https://www.bilibili.com/video/${card.desc.bvid}` : `https://www.bilibili.com/video/av${card_data.aid}`,\n            author: card.desc.user_profile.info.uname,\n        };\n    });\n\n    return {\n        title: `${name} 关注视频动态`,\n        link: 'https://t.bilibili.com/?tab=8',","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/bilibili/followings-video.ts#L46-L82","documentation":"Generic Error thrown by the followings-video route when the Bilibili dynamic_new API returns any non-zero code that is NOT -6 or 4100000. The message includes the raw code and API message. This is a catch-all for unexpected Bilibili API error codes (e.g., -101, -352, -403, etc.) that the route does not specifically handle.","triggerScenarios":"response.data.code is truthy and falls outside {-6, 4100000}. Common codes include -101 (not logged in via different path), -352 (risk-control variant), -404 (not found), or temporary Bilibili backend errors.","commonSituations":"Bilibili API changed and returns a new error code; temporary backend outage returning code -500 or -509; rate limiting returning an unhandled code; the dynamic feed for this user is empty/deleted.","solutions":["Check the server log — logger.error(JSON.stringify(data)) prints the full response; identify the specific code.","If code indicates rate limiting (-509), reduce polling frequency.","If code is -101, the cookie may be incomplete (missing DedeUserID); refresh it.","Retry after a few minutes if it appears to be a transient Bilibili backend issue.","File an issue or PR to handle the new code specifically if it persists."],"exampleFix":"// before\nthrow new Error(`Got error code ${data.code} while fetching: ${data.message}`);\n\n// after: log full context and provide actionable hint\nlogger.error(`Bilibili dynamic_new failed for uid=${uid}: ${JSON.stringify(data)}`);\nthrow new Error(`Bilibili API error ${data.code}: ${data.message}. If this persists, update the cookie or reduce request frequency.`);","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    const data = response.data;\n    if (data.code) {\n        logger.error(JSON.stringify(data));\n        if (data.code === -6 || data.code === 4_100_000) {\n            throw new ConfigNotFoundError('Cookie issue');\n        }\n        throw new Error(`Unexpected Bilibili code ${data.code}: ${data.message}`);\n    }\n} catch (e) {\n    // Let RSSHub's error middleware handle it\n    throw e;\n}","preventionTips":["Log full API responses for unhandled codes to enable diagnosis.","Watch for new Bilibili error codes after API changes.","Handle transient codes with retry logic."],"tags":["bilibili","api-error","catch-all","rsshub"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}