DIYgod/RSSHub · error

Got error code ${data.code} while fetching: ${data.message}

Error message

Got error code ${data.code} while fetching: ${data.message}

What it means

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.

Source

Thrown at lib/routes/bilibili/followings-video.ts:64

    if (cookie === undefined) {
        throw new ConfigNotFoundError('缺少对应 uid 的 Bilibili 用户登录后的 Cookie 值');
    }

    const response = await got({
        method: 'get',
        url: `https://api.vc.bilibili.com/dynamic_svr/v1/dynamic_svr/dynamic_new?uid=${uid}&type=8`,
        headers: {
            Referer: `https://space.bilibili.com/${uid}/`,
            Cookie: cookie,
        },
    });
    const data = response.data;
    if (data.code) {
        logger.error(JSON.stringify(data));
        if (data.code === -6 || data.code === 4_100_000) {
            throw new ConfigNotFoundError('对应 uid 的 Bilibili 用户的 Cookie 已过期');
        }
        throw new Error(`Got error code ${data.code} while fetching: ${data.message}`);
    }
    const cards = data.data.cards;

    const out = cards.map((card) => {
        const card_data = JSON.parse(card.card);

        return {
            title: card_data.title,
            description: utils.renderUGCDescription(embed, card_data.pic, card_data.desc, card_data.aid, undefined, card.desc.bvid),
            pubDate: new Date(card_data.pubdate * 1000).toUTCString(),
            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}`,
            author: card.desc.user_profile.info.uname,
        };
    });

    return {
        title: `${name} 关注视频动态`,
        link: 'https://t.bilibili.com/?tab=8',

View on GitHub (pinned to bed535e087)

Solutions

  1. Check the server log — logger.error(JSON.stringify(data)) prints the full response; identify the specific code.
  2. If code indicates rate limiting (-509), reduce polling frequency.
  3. If code is -101, the cookie may be incomplete (missing DedeUserID); refresh it.
  4. Retry after a few minutes if it appears to be a transient Bilibili backend issue.
  5. File an issue or PR to handle the new code specifically if it persists.

Example fix

// before
throw new Error(`Got error code ${data.code} while fetching: ${data.message}`);

// after: log full context and provide actionable hint
logger.error(`Bilibili dynamic_new failed for uid=${uid}: ${JSON.stringify(data)}`);
throw new Error(`Bilibili API error ${data.code}: ${data.message}. If this persists, update the cookie or reduce request frequency.`);
Defensive patterns

Strategy: try-catch

Try / catch

try {
    const data = response.data;
    if (data.code) {
        logger.error(JSON.stringify(data));
        if (data.code === -6 || data.code === 4_100_000) {
            throw new ConfigNotFoundError('Cookie issue');
        }
        throw new Error(`Unexpected Bilibili code ${data.code}: ${data.message}`);
    }
} catch (e) {
    // Let RSSHub's error middleware handle it
    throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12). Data as JSON: /api/errors/bd580e235d3afc76. Report an issue: GitHub.