DIYgod/RSSHub · error · Error
未能获取鱼塘数据
Error message
未能获取鱼塘数据
What it means
Thrown by handleForumSection in the jandan (煎蛋) route when the forum '鱼塘' (bbs) API at /api/forum/posts/112928?page=1 returns a response whose numeric `code` field is not 0. The route treats code===0 as success and any other code as a total failure, surfacing a plain Error (Chinese: '未能获取鱼塘数据' = 'could not get fish-pond data'). It is a hard failure because the handler cannot build any items without forumData.data.list.
Source
Thrown at lib/routes/jandan/utils.ts:78
} as DataItem;
});
return { title, items };
};
/**
* Handle the forum/bbs section (鱼塘)
*/
export const handleForumSection = async (rootUrl: string): Promise<{ title: string; items: DataItem[]; link: string }> => {
const title = '煎蛋 - 鱼塘';
const currentUrl = `${rootUrl}/new/forum`;
const forumId = 112928;
const apiUrl = `${rootUrl}/api/forum/posts/${forumId}?page=1`;
const forumData = await ofetch(apiUrl);
if (forumData.code !== 0) {
throw new Error('未能获取鱼塘数据');
}
const items = forumData.data.list.map(
(post) =>
({
author: post.author_name,
title: post.title,
pubDate: parseDate(post.create_time),
updated: parseDate(post.update_time),
link: `${rootUrl}/new/forum/topic/${post.post_id}`,
category: post.reply_count > 0 ? [`${post.reply_count}条回复`] : undefined,
}) as DataItem
);
return { title, items, link: currentUrl };
};
/**View on GitHub (pinned to bed535e087)
Solutions
- Verify the forumId 112928 still exists by opening https://jandan.net/api/forum/posts/112928?page=1 in a browser and checking the `code` field
- If the endpoint changed, update the apiUrl template and forumId in lib/routes/jandan/utils.ts:73-74 to match the current 煎蛋 API
- If code is non-zero only transiently, treat it as retryable: wrap ofetch in a retry/backoff before throwing
- Log the full forumData object (not just code) in the error so the new failure mode is diagnosable
Example fix
// before
if (forumData.code !== 0) {
throw new Error('未能获取鱼塘数据');
}
// after
if (forumData.code !== 0 || !forumData.data?.list) {
throw new Error(`未能获取鱼塘数据 (code=${forumData.code}, msg=${forumData.message ?? 'n/a'})`);
} Defensive patterns
Strategy: try-catch
Validate before calling
// Before calling handleForumSection, probe the API contract
async function isForumApiHealthy(rootUrl: string): Promise<boolean> {
try {
const data = await ofetch(`${rootUrl}/api/forum/posts/112928?page=1`);
return data?.code === 0 && Array.isArray(data?.data?.list);
} catch {
return false;
}
} Type guard
interface JandanForumResponse { code: number; data?: { list?: unknown[] }; message?: string }
function isForumResponse(v: unknown): v is JandanForumResponse {
return typeof v === 'object' && v !== null && typeof (v as JandanForumResponse).code === 'number';
} Try / catch
try {
return await handleForumSection(rootUrl);
} catch (e) {
if (e instanceof Error && e.message.includes('鱼塘')) {
// transient API failure — retry once after backoff, then surface a friendly feed-level error
await new Promise((r) => setTimeout(r, 1500));
return await handleForumSection(rootUrl);
}
throw e;
} Prevention
- Monitor the jandan forum API with a health check and alert on code!==0
- Keep forumId configurable rather than hardcoded so restructures are a config change
- Include the upstream code/message in thrown errors for faster triage
- Decouple transport success (HTTP 200) from business success (code===0) explicitly
When it happens
Trigger: ofetch to `${rootUrl}/api/forum/posts/112928?page=1` succeeds at the transport level but the JSON body has `code` set to a non-zero value (e.g. 1, -1, 404). Common when the hardcoded forumId 112928 was deleted/renamed by 煎蛋, when the site is rate-limiting the API, or when the API endpoint shape changed so `code` is no longer the success field.
Common situations: Site restructure that moves/renames the forum board; upstream API returning an error envelope while still sending HTTP 200; deploying with a stale rootUrl; transient backend outages of jandan's API.
Related errors
- 没有获取到内容,可能需要更新解析规则
- this route is empty, please check the original site or <a hr
- Unknown type: ${item.type}
- Comic Not Found - ${name}
- Empty content: ${articleUrl}
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/523e5d9f3007b3da.
Report an issue: GitHub.