DIYgod/RSSHub · error · Error
${JSON.stringify(collect)}
Error message
${JSON.stringify(collect)} What it means
Generic Error thrown in renderCollect when collect is truthy but collect.code !== 0 — i.e. the collect API call succeeded at the transport level but Xiaohongshu returned a non-zero business code. The entire response is JSON.stringify'd into the message for diagnosis.
Source
Thrown at lib/routes/xiaohongshu/user.ts:118
notes.flatMap((n) =>
n.map(({ noteCard }) => {
const coverUrl = noteCard.cover.infoList.pop().url;
return {
title: noteCard.displayTitle,
link: coverUrl,
guid: noteCard.displayTitle,
description: `<img src="${coverUrl}" width="${noteCard.cover.width}" height="${noteCard.cover.height}"><br>${noteCard.displayTitle}`,
author: noteCard.user.nickname,
upvotes: noteCard.interactInfo.likedCount,
};
})
);
const renderCollect = (collect) => {
if (!collect) {
throw new InvalidParameterError('该用户已设置收藏内容不可见');
}
if (collect.code !== 0) {
throw new Error(JSON.stringify(collect));
}
if (!collect.data.notes.length) {
throw new InvalidParameterError('该用户已设置收藏内容不可见');
}
return collect.data.notes.map((item) => ({
title: item.display_title,
link: `${url}/${item.note_id}`,
description: `<img src ="${item.cover.info_list.pop().url}"><br>${item.display_title}`,
author: item.user.nickname,
upvotes: item.interact_info.likedCount,
}));
};
return {
title,
description,
image,
link: url,View on GitHub (pinned to bed535e087)
Solutions
- Read the JSON in the error message — the code and msg fields identify the exact business error.
- Retry after a delay if it is risk-control related (often pairs with error 639 under heavier load).
- Provide a valid XIAOHONGSHU_COOKIE (config.xiaohongshu.cookie) so the collect API authorizes.
Defensive patterns
Strategy: try-catch
Validate before calling
// Inspect the API code before rendering
if (collect && typeof collect === 'object' && 'code' in collect && collect.code !== 0) {
throw new Error(`xiaohongshu collect API code=${collect.code} msg=${collect.msg ?? ''}`);
} Type guard
function isXiaohongshuCollectApiError(e: unknown): boolean {
if (!(e instanceof Error)) return false;
try { JSON.parse(e.message); return true; } catch { return false; }
} Try / catch
try {
return renderCollect(collect);
} catch (e) {
if (isXiaohongshuCollectApiError(e)) {
const body = JSON.parse((e as Error).message);
if (body.code === <riskControlCode>) await backoffAndRetry();
}
throw e;
} Prevention
- Provide a valid XIAOHONGSHU_COOKIE so the collect API does not return a business error.
- Parse the JSON message to map known codes to user-facing guidance.
- Rate-limit xiaohongshu requests to avoid risk-control codes.
When it happens
Trigger: The /api/sns/web/v2/note/collect/page XHR returned a body whose top-level code is non-zero (e.g. auth required, rate limited, parameter error) — user.ts:117-118.
Common situations: Xiaohongshu flagged the request (risk control without the full captcha page), the cookie/session is partial, or the user_id path is invalid.
Related errors
- ${tagResponse.msg}
- Failed to retrieve user settings from MangaDex API.
- Failed to retrieve user follows from MangaDex API.
- Failed to retrieve user follows from MangaDex API.
- Failed to retrieve user follows from MangaDex API.
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/c4c4f3048c00d3bb.
Report an issue: GitHub.