{"record":{"id":"a247bcdd16bef250","repo":"DIYgod/RSSHub","slug":"error-a247bc","errorCode":null,"errorMessage":"没有获取到内容，可能需要更新解析规则","messagePattern":"没有获取到内容，可能需要更新解析规则","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/routes/jandan/utils.ts","lineNumber":113,"sourceCode":"\n/**\n * Handle other sections (问答, 树洞, 随手拍, 女装, 无聊图)\n */\nexport const handleCommentSection = async (rootUrl: string, category: string): Promise<{ title: string; items: DataItem[] }> => {\n    const currentUrl = `${rootUrl}/${category}`;\n\n    const { pageId, title: pageTitle } = await extractPageMeta(currentUrl);\n    const title = pageTitle || `煎蛋 - ${category}`;\n\n    if (!pageId) {\n        throw new Error('无法从页面中获取到帖子ID，可能网站结构已变更');\n    }\n\n    const apiUrl = `${rootUrl}/api/comment/post/${pageId}?order=desc&page=0`;\n    const commentsData = await ofetch(apiUrl);\n\n    if (commentsData.code !== 0) {\n        throw new Error('没有获取到内容，可能需要更新解析规则');\n    }\n\n    const items = commentsData.data.list.map((comment) => {\n        const content = comment.content.replaceAll(/img src=\"(.*?)\"/g, (match, src) => match.replace(src, () => src.replace(/^https?:\\/\\/(\\w+)\\.moyu\\.im/, 'https://$1.sinaimg.cn')));\n\n        return {\n            author: comment.author,\n            title: `${comment.author}: ${sanitizeHtml(content, { allowedTags: [], allowedAttributes: {} })}`,\n            description: content,\n            pubDate: parseDate(comment.date_gmt),\n            link: `${rootUrl}/t/${comment.id}`,\n        } as DataItem;\n    });\n\n    return { title, items };\n};\n","sourceCodeStart":95,"sourceCodeEnd":130,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/jandan/utils.ts#L95-L130","documentation":"Thrown by handleCommentSection in the jandan route after it fetched `/api/comment/post/${pageId}?order=desc&page=0` and the response's `code` field is not 0 (Chinese: 'no content obtained, parsing rules may need updating'). Unlike the pageId error, this fires downstream: the page was found but the comment API rejected it.","triggerScenarios":"The extracted pageId is valid syntactically but the comments API returns a non-zero code — most often because the pageId resolved from cache is for a board that no longer exists, the API added a new auth/header requirement, or the category slug maps to a page without a comment thread.","commonSituations":"Stale cached pageMeta pointing at a removed board; API version bump that changed the success-code contract; rate limiting returning code!==0 with HTTP 200; category that legitimately has no comment thread.","solutions":["Bust the `jandan:pageMeta:${url}` cache so a fresh pageId is extracted","Manually call /api/comment/post/<pageId>?order=desc&page=0 to see the actual code and message returned","If the API contract changed, update the code check and the data.list mapping in lib/routes/jandan/utils.ts:112-116","If some categories legitimately return no comments, downgrade to an empty feed instead of throwing"],"exampleFix":"// before\nif (commentsData.code !== 0) {\n    throw new Error('没有获取到内容，可能需要更新解析规则');\n}\n// after\nif (commentsData.code !== 0) {\n    throw new Error(`没有获取到内容 (code=${commentsData.code}, pageId=${pageId}): ${commentsData.message ?? ''}`);\n}","handlingStrategy":"try-catch","validationCode":"// Confirm the comment API will succeed for a given pageId before relying on it\nasync function commentApiOk(rootUrl: string, pageId: string): Promise<boolean> {\n  try {\n    const d = await ofetch(`${rootUrl}/api/comment/post/${pageId}?order=desc&page=0`);\n    return d?.code === 0;\n  } catch {\n    return false;\n  }\n}","typeGuard":"interface JandanCommentResponse { code: number; data?: { list?: unknown[] } }\nfunction isCommentResponse(v: unknown): v is JandanCommentResponse {\n  return typeof v === 'object' && v !== null && typeof (v as JandanCommentResponse).code === 'number';\n}","tryCatchPattern":"try {\n  return await handleCommentSection(rootUrl, category);\n} catch (e) {\n  if (e instanceof Error && e.message.includes('没有获取到内容')) {\n    // pageMeta cache may hold a stale/removed board — clear and retry once\n    throw new Error('jandan comment API rejected pageId — refresh pageMeta cache and retry');\n  }\n  throw e;\n}","preventionTips":["Invalidate pageMeta cache when the comment API returns code!==0","Treat code!==0 as retryable for transient outages but permanent for removed boards","Distinguish 'pageId stale' from 'API contract changed' by logging the code value","Guard against categories that legitimately have no comment thread"],"tags":["api-response","scraping","cache-staleness"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}