DIYgod/RSSHub · error
response.message ?? response.msg ?? `Error code ${response.c
Error message
response.message ?? response.msg ?? `Error code ${response.code}` What it means
Thrown by the message-sessions route after https://api.vc.bilibili.com/session_svr/.../get_sessions returns HTTP 200 with a non-zero business code. The fallback chain (response.message ?? response.msg ?? `Error code N`) reflects that some bilibili session endpoints report the human text under `message` and others under `msg`; both are tried before a bare code. A non-zero code means the Cookie was transmitted but Bilibili rejected the call at the application layer.
Source
Thrown at lib/routes/bilibili/message-sessions.ts:169
}
const response = await ofetch<SessionResponse>('https://api.vc.bilibili.com/session_svr/v1/session_svr/get_sessions', {
query: {
session_type: 1,
group_fold: 1,
unfollow_fold: 0,
sort_rule: 2,
build: 0,
mobi_app: 'web',
},
headers: {
Referer: 'https://message.bilibili.com/',
Cookie: cookie,
},
});
if (response.code !== 0) {
throw new Error(response.message ?? response.msg ?? `Error code ${response.code}`);
}
const sessionList = response.data.session_list || [];
const talkerIds = sessionList.filter((s) => s.session_type === 1).map((s) => s.talker_id);
// Fetch user info for all talkers
let userCards: Record<string, UserInfo> = {};
if (talkerIds.length > 0) {
const userCardsResponse = await cache.tryGet(
`bilibili-user-cards-${talkerIds.join(',')}`,
async () => {
const res = await ofetch<UserCardsResponse>('https://api.bilibili.com/x/polymer/pc-electron/v1/user/cards', {
query: {
uids: talkerIds.join(','),
build: 0,
mobi_app: 'web',
},
headers: {View on GitHub (pinned to bed535e087)
Solutions
- Refresh BILIBILI_COOKIE_{uid} from a new bilibili.com login (full Cookie including SESSDATA, bili_jct, DedeUserID).
- Decode the numeric code: -101 session invalid, -352/-799 risk control (slow down / rotate), -403 permission.
- Increase the RSS reader poll interval (>= 10 min) and avoid duplicate instances hammering the same account.
- Verify the cookie's DedeUserID matches the uid in the path.
Example fix
// before
if (response.code !== 0) {
throw new Error(response.message ?? response.msg ?? `Error code ${response.code}`);
}
// after
if (response.code !== 0) {
if (response.code === -101) {
throw new ConfigNotFoundError(`Cookie for uid ${uid} expired (code -101). Update BILIBILI_COOKIE_${uid}.`);
}
throw new Error(response.message ?? response.msg ?? `Error code ${response.code}`);
} Defensive patterns
Strategy: retry
Validate before calling
import ofetch from '@/utils/ofetch';
import { config } from '@/config';
async function cookieValid(uid: string) {
const cookie = config.bilibili.cookies[uid];
if (!cookie) return false;
const r = await ofetch<{ code: number }>('https://api.bilibili.com/x/web-interface/nav', { headers: { Cookie: cookie } });
return r.code === 0;
} Type guard
// vc.bilibili.com envelopes may carry the text in `message` or `msg`
interface VcEnv<T> { code: number; message?: string; msg?: string; data?: T }
function isVcOk<T>(r: VcEnv<T>): r is VcEnv<T> & { code: 0; data: T } { return r.code === 0; } Try / catch
try {
if (response.code !== 0) throw new Error(response.message ?? response.msg ?? `Error code ${response.code}`);
} catch (e) {
const m = e instanceof Error ? e.message : '';
if (m.includes('-101')) throw new Error(`Refresh BILIBILI_COOKIE_${uid}`);
if (m.includes('-352') || m.includes('-799')) await backoffRetry();
throw e;
} Prevention
- Periodically validate the cookie via /x/web-interface/nav.
- Cache session list output for several minutes (cache.tryGet).
- Poll >= 10 minute intervals; avoid duplicate instances per account.
- Confirm DedeUserID matches the path uid.
When it happens
Trigger: GET /bilibili/message/sessions/:uid where the configured cookie is expired (code -101), the account is rate-limited, or risk control flagged the session (-352). The dual message/msg lookup fires for both the vc.bilibili.com and x.bilibili.com response shapes.
Common situations: Expired SESSDATA; cookie missing bili_jct/DedeUserID; account under anti-crawler cooldown from frequent polling; bilibili changed which field carries the error text (hence the defensive ?? chain).
Related errors
- response.message ?? `Error code ${response.code}`
- response.message ?? `Error code ${response.code}`
- response.message ?? response.msg ?? `Error code ${response.c
- msgUnread.message ?? `Error code ${msgUnread.code}`
- It looks like something went wrong when querying the Bilibil
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/f298c68a7457b842.
Report an issue: GitHub.