{"record":{"id":"280fe0a3d485b869","repo":"DIYgod/RSSHub","slug":"invalid-id-280fe0","errorCode":null,"errorMessage":"Invalid id","messagePattern":"Invalid id","errorType":"validation","errorClass":"InvalidParameterError","httpStatus":null,"severity":"error","filePath":"lib/routes/zhubai/index.ts","lineNumber":32,"sourceCode":"        requirePuppeteer: false,\n        antiCrawler: false,\n        supportBT: false,\n        supportPodcast: false,\n        supportScihub: false,\n    },\n    name: '文章',\n    maintainers: ['naixy28'],\n    handler,\n    description: `::: tip\n在路由末尾处加上 \\`?limit=限制获取数目\\` 来限制获取条目数量，默认值为\\`20\\`\n:::`,\n};\n\nasync function handler(ctx) {\n    const id = ctx.req.param('id');\n    const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 20;\n    if (!isValidHost(id)) {\n        throw new InvalidParameterError('Invalid id');\n    }\n\n    const response = await got({\n        method: 'get',\n        url: `https://${id}.zhubai.love/api/publications/${id}/posts?publication_id_type=token&limit=${limit}`,\n        headers: {\n            Referer: `https://${id}.zhubai.love/`,\n        },\n    });\n    const data = response.data.data;\n    const { name, description } = data[0].publication;\n\n    return {\n        title: name,\n        link: `https://${id}.zhubai.love/`,\n        description,\n        item: data.map((item) => ({\n            title: item.title,","sourceCodeStart":14,"sourceCodeEnd":50,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/zhubai/index.ts#L14-L50","documentation":"An `InvalidParameterError` from the zhubai route when the `:id` path parameter fails `isValidHost`. The `id` is used both as the publication subdomain (`https://${id}.zhubai.love`) and in the API URL, so it must be a valid DNS host label; anything else is rejected before any request is made.","triggerScenarios":"The caller passes an `id` that is not a valid hostname label — contains dots, slashes, spaces, protocol, or special characters; e.g. someone pastes a full URL or an email-like value instead of the bare publication token.","commonSituations":"User copies `https://foo.zhubai.love` or `foo.zhubai.love` instead of just `foo`; a malformed request injects path separators; the publication token was mistyped with invalid characters.","solutions":["Pass only the bare publication subdomain token, e.g. `/zhubai/mypublication`.","If you have the full site URL, extract the subdomain segment (`foo` from `foo.zhubai.love`) before calling the route.","Strip protocol, trailing path, and dots from the value before using it as `id`."],"exampleFix":"// before — full URL passed\n// GET /zhubai/https://foo.zhubai.love  -> Invalid id\n// after — bare subdomain token\n// GET /zhubai/foo","handlingStrategy":"validation","validationCode":"function normalizeZhubaiId(raw) {\n    let id = raw.replace(/^https?:\\/\\//, '').replace(/\\.zhubai\\.love.*$/, '').replace(/\\/$/, '');\n    if (!/^[a-z0-9-]+$/i.test(id)) {\n        throw new Error(`Invalid zhubai id: ${raw}`);\n    }\n    return id;\n}","typeGuard":"function isValidZhubaiId(id: string): boolean {\n    return /^[a-z0-9-]+$/i.test(id);\n}","tryCatchPattern":null,"preventionTips":["Validate the id is a clean host label before building the subdomain/API URL.","Strip protocol and domain suffix when accepting pasted URLs.","Reject values containing dots, slashes, or spaces early."],"tags":["zhubai","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"}