{"record":{"id":"d913e8fe8f67b7c9","repo":"DIYgod/RSSHub","slug":"cookie-d913e8","errorCode":null,"errorMessage":"缺少雪球用户登录后的 Cookie 值","messagePattern":"缺少雪球用户登录后的 Cookie 值","errorType":"exception","errorClass":"ConfigNotFoundError","httpStatus":503,"severity":"error","filePath":"lib/routes/xueqiu/user-stock.ts","lineNumber":41,"sourceCode":"        supportScihub: false,\n    },\n    radar: [\n        {\n            source: ['xueqiu.com/u/:id'],\n        },\n    ],\n    name: '用户自选动态',\n    maintainers: ['hillerliao'],\n    handler,\n    description: `::: warning\n用户自选动态需要登录后的 Cookie 值，所以只能自建，详情见部署页面的配置模块。\n:::`,\n};\n\nasync function handler(ctx) {\n    const cookie = config.xueqiu.cookies;\n    if (cookie === undefined) {\n        throw new ConfigNotFoundError('缺少雪球用户登录后的 Cookie 值');\n    }\n\n    const id = ctx.req.param('id');\n\n    const {\n        data: { stocks: data },\n    } = await ofetch(`https://stock.xueqiu.com/v5/stock/portfolio/stock/list.json?category=1&size=1000&uid=${id}`, {\n        headers: {\n            Cookie: cookie,\n            Referer: `https://xueqiu.com/u/${id}`,\n        },\n    });\n\n    const {\n        user: { screen_name },\n    } = await ofetch('https://xueqiu.com/statuses/original/show.json', {\n        query: {\n            user_id: id,","sourceCodeStart":23,"sourceCodeEnd":59,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/xueqiu/user-stock.ts#L23-L59","documentation":"ConfigNotFoundError thrown by the Xueqiu user-stock handler when config.xueqiu.cookies is undefined. The portfolio/list.json endpoint requires an authenticated Cookie header (sent verbatim in the request), so the route refuses to proceed without it. Same Chinese message as the timeline route.","triggerScenarios":"Any request to /xueqiu/user-stock/:id when XUEQIU_COOKIES is unset. The guard fires before the ofetch to stock.xueqiu.com/v5/stock/portfolio/stock/list.json, which would otherwise 400/401 without a valid cookie.","commonSituations":"Same as 647: self-hosted instance without XUEQIU_COOKIES; the route is self-host-only and documented as needing a login cookie; cookie expired and the operator removed it.","solutions":["Set XUEQIU_COOKIES to the Cookie header from a logged-in xueqiu.com session and restart RSSHub.","Ensure the cookie includes the tokens Xueqiu's stock API validates (xq_a_token).","Refresh periodically — Xueqiu login sessions expire."],"exampleFix":"// before\nif (cookie === undefined) {\n    throw new ConfigNotFoundError('缺少雪球用户登录后的 Cookie 值');\n}\n\n// after\nif (cookie === undefined) {\n    throw new ConfigNotFoundError('缺少雪球用户登录后的 Cookie 值 (set XUEQIU_COOKIES env var to the Cookie header of a logged-in xueqiu.com session)');\n}","handlingStrategy":"validation","validationCode":"import { config } from '@/config';\nfunction requireXueqiuCookie() {\n    const cookie = config.xueqiu.cookies;\n    if (cookie === undefined) {\n        throw new ConfigNotFoundError('Set the XUEQIU_COOKIES env var to the Cookie header from a logged-in xueqiu.com session.');\n    }\n    return cookie as string;\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Configure XUEQIU_COOKIES before subscribing to any user-stock feed.","Ensure the cookie includes xq_a_token, which the portfolio API validates.","Refresh the cookie when Xueqiu sessions expire."],"tags":["xueqiu","config","cookie","auth","finance"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}