{"record":{"id":"6f9d75c14483e870","repo":"DIYgod/RSSHub","slug":"error-6f9d75","errorCode":null,"errorMessage":"未获取到数据！","messagePattern":"未获取到数据！","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/routes/mihoyo/bbs/user-post.ts","lineNumber":40,"sourceCode":"};\n\nasync function handler(ctx) {\n    const uid = ctx.req.param('uid');\n    const size = ctx.req.query('limit') || '20';\n    const searchParams = {\n        uid,\n        size,\n    };\n    const link = `https://www.miyoushe.com/ys/accountCenter/postList?id=${uid}`;\n    const url = 'https://bbs-api.miyoushe.com/post/wapi/userPost';\n    const response = await got({\n        method: 'get',\n        url,\n        searchParams,\n    });\n    const list = response?.data?.data?.list;\n    if (!list) {\n        throw new Error('未获取到数据！');\n    }\n    const username = list[0]?.user.nickname;\n    const title = `米游社 - ${username} 的发帖`;\n    const items = list.map((e) => post2item(e));\n\n    const data = {\n        title,\n        link,\n        item: items,\n    };\n    return data;\n}\n","sourceCodeStart":22,"sourceCodeEnd":53,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/mihoyo/bbs/user-post.ts#L22-L53","documentation":"Thrown by the Miyoushe per-user posts route (/mihoyo/bbs/user-post/:uid) when the call to bbs-api.miyoushe.com/post/wapi/userPost returns a response whose .data.data.list is falsy. Like the timeline route it is a bare `throw new Error('未获取到数据！')`. Unlike timeline, this route needs no cookie — it only depends on the uid path parameter being valid and the user having posts.","triggerScenarios":"The handler GETs userPost with searchParams {uid, size}. The error fires when: (a) the uid does not correspond to a real miyoushe account; (b) the account exists but has published zero posts (list null/empty); (c) miyoushe's risk-control returns a non-data envelope; (d) the API response schema changed so .data.data.list moved.","commonSituations":"A subscriber pastes a uid copied from the wrong field (e.g. a topic id instead of a user id); the target user deleted all posts or was banned; miyoushe enforces login to view any userPost and now returns an auth-required envelope for anonymous callers.","solutions":["Verify the uid by opening https://www.miyoushe.com/ys/accountCenter/postList?id=<uid> in a browser — if the page shows no posts or a 404, the uid is wrong or the user has no posts.","Reproduce the upstream call (curl 'https://bbs-api.miyoushe.com/post/wapi/userPost?uid=<uid>&size=20') and inspect the JSON to distinguish an auth/risk-control envelope from a genuinely empty list.","If miyoushe now requires a cookie for userPost (previously anonymous), set MIHOYO_COOKIE and add a Cookie header to the got call mirroring the timeline route.","If the uid is confirmed valid but posts are gated, switch to a different miyoushe endpoint that the user's public profile exposes."],"exampleFix":"// before\nconst list = response?.data?.data?.list;\nif (!list) {\n    throw new Error('未获取到数据！');\n}\n\n// after — distinguish not-found from empty/gated\nconst list = response?.data?.data?.list;\nif (!list) {\n    if (response?.data?.message?.includes('登录') || response?.data?.retcode !== undefined) {\n        throw new Error(`miyoushe userPost rejected the request: ${response?.data?.message ?? response?.data?.retcode}`);\n    }\n    throw new Error(`No posts for uid ${uid} (verify the uid at https://www.miyoushe.com/ys/accountCenter/postList?id=${uid})`);\n}","handlingStrategy":"validation","validationCode":"// Validate uid shape before the request\nconst uid = ctx.req.param('uid');\nif (!/^\\d{6,}$/.test(uid)) {\n    throw new InvalidParameterError(`uid must be a numeric miyoushe user id, got: ${uid}`);\n}","typeGuard":"function isUserPostEnvelope(r: unknown): r is { data: { data: { list: unknown[] } } } {\n    return !!r && typeof r === 'object' && Array.isArray((r as any)?.data?.data?.list);\n}","tryCatchPattern":null,"preventionTips":["Validate the uid format (numeric) before fetching.","Inspect the upstream retcode/message and map it to a typed error instead of a bare 'no data'.","Handle the 'user has no posts' case as an empty feed rather than an error when the API confirms the user exists."],"tags":["api-data-empty","invalid-parameter","uid","mihoyo"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}