{"record":{"id":"be510e5adc98b303","repo":"DIYgod/RSSHub","slug":"invalid-uid","errorCode":null,"errorMessage":"Invalid uid","messagePattern":"Invalid uid","errorType":"validation","errorClass":"InvalidParameterError","httpStatus":null,"severity":"error","filePath":"lib/routes/zcool/user.ts","lineNumber":48,"sourceCode":"            target: '/user/:id',\n        },\n    ],\n    name: '用户作品',\n    description: `例如:\n\n站酷的个人主页 \\`https://baiyong.zcool.com.cn\\` 对应 rss 路径 \\`/zcool/user/baiyong\\`\n\n站酷的个人主页 \\`https://www.zcool.com.cn/u/568339\\` 对应 rss 路径 \\`/zcool/user/568339\\``,\n    maintainers: ['junbaor'],\n    handler,\n};\n\nasync function handler(ctx) {\n    const uid = ctx.req.param('uid');\n    let pageUrl = `https://www.zcool.com.cn/u/${uid}`;\n    if (Number.isNaN(uid)) {\n        if (!isValidHost(uid)) {\n            throw new InvalidParameterError('Invalid uid');\n        }\n        pageUrl = `https://${uid}.zcool.com.cn`;\n    }\n    const { data: response } = await got(pageUrl);\n    const $ = load(response);\n    const data = JSON.parse($('script#__NEXT_DATA__').text());\n\n    const workList = data.props.pageProps.workList.map((item) => ({\n        title: item.title,\n        link: item.pageUrl,\n        pubDate: parseDate(item.publishTime, 'x'),\n        category: [item.objectTypeStr, item.cateStr, item.subCateStr, ...item.tags],\n    }));\n\n    const items = await Promise.all(\n        workList.map((item) =>\n            cache.tryGet(item.link, async () => {\n                const { data: response } = await got(item.link);","sourceCodeStart":30,"sourceCodeEnd":66,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/zcool/user.ts#L30-L66","documentation":"Thrown by the ZCOOL user route when the `:uid` path parameter is non-numeric (so it is treated as a personal-domain subdomain prefix) but fails `isValidHost`. The route accepts either a numeric user ID (`/zcool/user/568339`) or a subdomain-style alias (`/zcool/user/baiyong`); a value that is neither a number nor a valid host label is rejected.","triggerScenarios":"The caller supplies a `uid` that is not all-digits and is not a valid DNS host label — e.g. contains slashes, spaces, dots, or special characters; or a copy-paste of a full URL instead of the bare alias.","commonSituations":"User pastes `https://baiyong.zcool.com.cn` or `www.zcool.com.cn/u/568339` into the path instead of just `baiyong` / `568339`; a malformed client request injects unexpected characters into the param.","solutions":["Use only the bare alias or numeric ID: `/zcool/user/baiyong` or `/zcool/user/568339`.","If you have a full profile URL, extract the subdomain prefix (`baiyong` from `baiyong.zcool.com.cn`) or the numeric segment before calling the route.","Strip any leading/trailing slashes or protocol before passing the value as `uid`."],"exampleFix":"// before — caller passes a full URL segment\n// GET /zcool/user/https://baiyong.zcool.com.cn  -> Invalid uid\n// after — pass the bare alias or numeric id\n// GET /zcool/user/baiyong\n// GET /zcool/user/568339","handlingStrategy":"validation","validationCode":"function normalizeZcoolUid(raw) {\n    // numeric id\n    if (/^\\d+$/.test(raw)) return raw;\n    // subdomain alias extracted from a full URL\n    const m = raw.match(/^(?:https?:\\/\\/)?([a-z0-9-]+)\\.zcool\\.com\\.cn/i);\n    if (m) return m[1];\n    // bare alias\n    if (/^[a-z0-9-]+$/i.test(raw)) return raw;\n    throw new Error(`Invalid zcool uid: ${raw}`);\n}","typeGuard":"function isValidZcoolUid(uid: string): boolean {\n    return /^\\d+$/.test(uid) || /^[a-z0-9-]+$/i.test(uid);\n}","tryCatchPattern":null,"preventionTips":["Validate the uid is either all-digits or a clean host label before constructing the route URL.","If accepting user-pasted URLs, extract the subdomain or numeric segment server-side rather than passing the raw string.","Strip leading/trailing slashes and protocol prefixes before validation."],"tags":["zcool","validation","route-parameter","invalid-parameter"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}