{"record":{"id":"e5abbafea873b517","repo":"DIYgod/RSSHub","slug":"error-e5abba","errorCode":null,"errorMessage":"没有获取到数据","messagePattern":"没有获取到数据","errorType":"exception","errorClass":"Error","httpStatus":503,"severity":"error","filePath":"lib/routes/eleduck/posts.ts","lineNumber":62,"sourceCode":"| 12 | 英语     |\n| 14 | 电鸭官方 |\n| 15 | 独立产品 |\n| 17 | 闲话开源 |\n| 19 | Web3     |\n| 21 | 设计     |\n| 22 | 人才库   |\n| 23 | Upwork   |\n| 24 | 经验课   |`,\n};\n\nasync function handler(ctx) {\n    const cid = ctx.req.param('id') || 0;\n\n    const response = await got(`https://svc.eleduck.com/api/v1/posts?category=${cid}&sort=-published_at&page=1`);\n\n    const { posts } = response.data;\n    if (posts === undefined) {\n        throw new Error('没有获取到数据');\n    }\n\n    const cname = await getCateName(cid);\n\n    return {\n        title: `电鸭社区的文章--${cname}`,\n        link: `https://eleduck.com/categories/${cid}`,\n        description: `电鸭社区的文章,栏目为${cname}`,\n        item: posts.map((item) => ({\n            title: item.title,\n            description: item.summary,\n            pubDate: item.published_at,\n            link: `https://eleduck.com/${item.category.id === 22 ? 'tposts' : 'posts'}/${item.id}`,\n            author: item.user.nickname,\n        })),\n    };\n}\n","sourceCodeStart":44,"sourceCodeEnd":80,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/eleduck/posts.ts#L44-L80","documentation":"Thrown when the Eleduck (电鸭社区) posts API at `svc.eleduck.com/api/v1/posts` returns a response whose `data` object does not contain a `posts` field. The check `posts === undefined` catches cases where the API returned an error object, empty body, or changed its response shape. The Chinese message means 'No data retrieved'.","triggerScenarios":"A user passes a category `id` that does not exist on Eleduck (e.g., `/eleduck/posts/999`). The API returns a top-level error object without a `posts` array. Alternatively, the Eleduck API is temporarily down or changed its response format.","commonSituations":"User passes a category id not listed in the route description table (valid ids: 0–5, 10, 12, 14, 15, 17, 19, 21–24). The Eleduck service undergoes maintenance. A network proxy or CDN returns an HTML error page that ofetch/got parses as an object without a posts field.","solutions":["Verify the category id is valid by checking the route description table or visiting `https://eleduck.com/categories/<id>`.","If the id is valid, the Eleduck API may be temporarily unavailable — retry after a few minutes.","Log `response.data` to inspect the full API response and determine if the schema changed.","If the API endpoint moved, update the URL in the got() call."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"const VALID_CATEGORY_IDS = new Set(['0','1','2','3','4','5','10','12','14','15','17','19','21','22','23','24']);\n\nfunction validateCategoryId(cid: string | undefined): string {\n    const resolved = cid ?? '0';\n    if (!VALID_CATEGORY_IDS.has(resolved)) {\n        throw new InvalidParameterError(`Invalid category id: ${cid}`);\n    }\n    return resolved;\n}","typeGuard":"function isDefinedPosts(response: unknown): response is { posts: unknown[] } {\n    return typeof response === 'object' && response !== null &&\n        Array.isArray((response as any).posts);\n}","tryCatchPattern":null,"preventionTips":["Use only the documented category IDs from the route description.","Default to category 0 (all) if unsure.","Handle the case where the API returns a valid response but with no posts field."],"tags":["upstream-api","data-validation","response-shape-change","eleduck"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}