{"record":{"id":"295f5fd91a644967","repo":"DIYgod/RSSHub","slug":"invalid-type-type-295f5f","errorCode":null,"errorMessage":"Invalid type: ${type}","messagePattern":"Invalid type: (.+?)","errorType":"validation","errorClass":"InvalidParameterError","httpStatus":null,"severity":"error","filePath":"lib/routes/shiep/index.tsx","lineNumber":61,"sourceCode":"| -------------------- | ---------- | ---------- | ------ | ------ | ------ | ------ | ------ | -------------------------------- | --------------- | ------ | -------- | -------------------------- | ------------------ | ------ | ------------------------ | ------- | ------------------------- | -------------------- | --------------------- | ---------------- | ------------ |\n| office               | dwllc      | fzghc      | sjc    | bwc    | xsc    | rsc    | tgb    | fao                              | kyc             | jwc    | yjsc     | hqglc                      | sysyzcglc          | jjc    | lgxq                     | library | metc                      | ieetc                | cyb                   | kczx             | jszyzx       |\n| 389                  | 2649       | 291        | 199    | tzgg   | 3482   | 1695   | notice | tzgg                             | 834             | 227    | 1161     | 1616                       | 312                | 327    | 377                      | 4866    | tzgg                      | cxcy                 | 367                   | 3946             | 4247         |\n\n其它：\n\n| 新闻网 | 信息公开网 | 本科招生网 | 本科就业信息网 | 文明办  | 学习路上 | “学条例 守党纪” 专题网 | 上海新能源人才技术教育交流中心 | 上海绿色能源并网技术研究中心 | 能源电力智库 | 智能发电实验教学中心 |\n| ------ | ---------- | ---------- | -------------- | ------- | -------- | ---------------------- | ------------------------------ | ---------------------------- | ------------ | -------------------- |\n| news   | xxgk       | zs         | career         | wenming | ztjy     | xxjy                   | gec                            | green-energy                 | nydlzk       | spgc                 |\n| notice | zxgkxx     | zxxx       | tzgg           | 2202    | 5575     | 5973                   | 1959                           | 118                          | tzgg         | 4449                 |\n\n参数与来源页面对应规则为：\\`https://\\${type}.shiep.edu.cn/\\${id}/list.htm\\``,\n};\n\nasync function handler(ctx) {\n    const type = ctx.req.param('type');\n\n    if (!Object.keys(config).includes(type)) {\n        throw new InvalidParameterError(`Invalid type: ${type}`);\n    }\n\n    const { listSelector = '.list_item', pubDateSelector = '.Article_PublishDate', descriptionSelector = '.wp_articlecontent', title } = config[type];\n\n    if (!title) {\n        throw new InvalidParameterError(`Invalid type: ${type}`);\n    }\n\n    const host = `https://${type}.shiep.edu.cn`;\n    const id = ctx.req.param('id') || config[type].id;\n    const link = type === 'career' ? `${host}/news/index/tag/${id}` : `${host}/${id}/list.htm`;\n\n    const response = await got(link);\n    const $ = load(response.data);\n\n    const list = $(listSelector)\n        .toArray()\n        .map((item): DataItem & { link: string } => {","sourceCodeStart":43,"sourceCodeEnd":79,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/shiep/index.tsx#L43-L79","documentation":"An InvalidParameterError thrown when the :type path segment is not one of the keys in the shiep config object. The config object enumerates every supported subdomain/section (news, xxgk, zs, career, …); an unknown type cannot be mapped to a host, so the route rejects it before any network call.","triggerScenarios":"ctx.req.param('type') returns a value that is not a key of the config object imported from ./config, so `!Object.keys(config).includes(type)` is true. The user requested a subdomain/section that the route was never configured for.","commonSituations":"A typo in the type segment (e.g. 'new' instead of 'news'); using an old section name after the site reorganized; requesting a subdomain that exists on shiep.edu.cn but was never added to the config table.","solutions":["Consult the route description table (lib/routes/shiep/index.tsx lines 28-52) and use a documented type value.","If the section genuinely exists but is missing from config, add it to ./config with the correct id, host, and selectors.","Use the InvalidParameterError's 400-class behavior so subscribers see a clear bad-input response."],"exampleFix":"// before\nif (!Object.keys(config).includes(type)) {\n    throw new InvalidParameterError(`Invalid type: ${type}`);\n}\n\n// after — list the valid types in the error so the caller can self-correct\nconst VALID_TYPES = Object.keys(config);\nif (!VALID_TYPES.includes(type)) {\n    throw new InvalidParameterError(`Invalid type: ${type}. Valid types: ${VALID_TYPES.join(', ')}`);\n}","handlingStrategy":"validation","validationCode":"const VALID_TYPES = Object.keys(config);\nif (!VALID_TYPES.includes(type)) {\n    throw new InvalidParameterError(`Invalid type: ${type}. Valid types: ${VALID_TYPES.join(', ')}`);\n}","typeGuard":"const isValidShiepType = (t: string): t is keyof typeof config =>\n    Object.prototype.hasOwnProperty.call(config, t);","tryCatchPattern":null,"preventionTips":["Derive the valid-type set from the config object so docs and validation stay in sync.","List valid types in the InvalidParameterError message so callers can self-correct.","When adding a new section, update ./config and the documentation table together."],"tags":["validation","invalid-parameter","user-input","route-param"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}