{"record":{"id":"560daa0da363a852","repo":"DIYgod/RSSHub","slug":"invalid-type-parameter-560daa","errorCode":null,"errorMessage":"Invalid type parameter","messagePattern":"Invalid type parameter","errorType":"exception","errorClass":"Error","httpStatus":503,"severity":"warning","filePath":"lib/routes/nowcoder/hots.ts","lineNumber":72,"sourceCode":"    }\n    if (type === '2') {\n        link = `https://gw-c.nowcoder.com/api/sparta/hot-search/top-hot-pc?size=${size}&_=${Date.now()}&t=`;\n        const responseBody = (await got.get(link)).data;\n        if (responseBody.code !== 0) {\n            throw new Error(`接口错误，错误代码: ${responseBody.code}，错误原因: ${responseBody.msg}`);\n        }\n        const data = responseBody.data.result;\n        return {\n            title: '牛客网-全站热贴',\n            link: 'https://mnowpick.nowcoder.com/m/discuss/hot',\n            description: '牛客网-全站热贴',\n            item: data.map((item) => ({\n                title: item.title,\n                link: `https://www.nowcoder.com/feed/main/detail/${item.uuid}`,\n            })),\n        };\n    }\n    throw new Error('Invalid type parameter');\n}\n","sourceCodeStart":54,"sourceCodeEnd":74,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/nowcoder/hots.ts#L54-L74","documentation":"Thrown when the `type` path parameter for the nowcoder hots route is neither '1' (hot topics) nor '2' (hot posts). This is the final fallthrough after both `if (type === '1')` and `if (type === '2')` blocks fail to match. Only the two literal string values are accepted.","triggerScenarios":"A user requests `/nowcoder/hots/3`, `/nowcoder/hots/0`, or any type value other than '1' or '2'. Also triggered by typos like `/nowcoder/hots/hot` or numeric variants like `/nowcoder/hots/01`.","commonSituations":"User misunderstands the route parameter and passes an unsupported type. A radar rule or bookmarked URL references an outdated type value. Automated feed readers cycling through numeric indices hit unsupported values.","solutions":["Use only type '1' (hot topics) or '2' (hot posts), or omit the parameter entirely to default to '1'.","If Nowcoder added a new hot list type, add a new `if (type === 'N')` block before the throw on line 72.","Replace the final `throw new Error` with `throw new InvalidParametersError` for consistent HTTP 400 semantics."],"exampleFix":"// before\nthrow new Error('Invalid type parameter');\n\n// after — use InvalidParameterError for correct HTTP 400\nimport InvalidParameterError from '@/errors/types/invalid-parameter';\n// ...\nthrow new InvalidParameterError(`Invalid type parameter: '${type}'. Supported values: 1 (热议话题), 2 (全站热贴)`);","handlingStrategy":"validation","validationCode":"// Validate type before processing\nconst validTypes = new Set(['1', '2']);\nif (!validTypes.has(type)) {\n    throw new InvalidParameterError(\n        `Invalid type '${type}'. Must be one of: 1 (热议话题), 2 (全站热贴)`\n    );\n}","typeGuard":"function isValidHotType(type: string): type is '1' | '2' {\n    return type === '1' || type === '2';\n}","tryCatchPattern":null,"preventionTips":["Document supported type values in the route parameters description.","Validate type at the top of the handler with an early return.","Use InvalidParameterError instead of generic Error for HTTP 400 semantics."],"tags":["validation","nowcoder","invalid-parameter","chinese-site"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}