{"record":{"id":"fb0b530a468dc06f","repo":"DIYgod/RSSHub","slug":"error-fb0b53","errorCode":null,"errorMessage":"无效序列号, 请检查你的序列号是否正确.","messagePattern":"无效序列号, 请检查你的序列号是否正确\\.","errorType":"validation","errorClass":"InvalidParameterError","httpStatus":null,"severity":"warning","filePath":"lib/routes/lenovo/drive.tsx","lineNumber":40,"sourceCode":"    radar: [\n        {\n            source: ['lenovo.com.cn'],\n            target: '/drive/:selName',\n        },\n    ],\n    name: '驱动',\n    maintainers: ['cscnk52'],\n    handler,\n};\n\nexport async function handler(ctx) {\n    const selName = ctx.req.param('selName');\n    const link = `https://newsupport.lenovo.com.cn/api/drive/drive_listnew?searchKey=${selName}`;\n\n    const response = await ofetch(link);\n\n    if (response.statusCode !== 200) {\n        throw new InvalidParameterError('无效序列号, 请检查你的序列号是否正确.');\n    }\n\n    const driveList = response.data.partList.flatMap((part) => part.drivelist);\n\n    const items: DataItem[] = driveList.map(\n        (item) =>\n            ({\n                title: `${item.DriverName} ${item.Version}`,\n                link: `https://newsupport.lenovo.com.cn/driveDownloads_detail.html?driveId=${item.DriverEdtionId}`,\n                description: renderToString(<DriveDescription driveName={item.DriverName} driveCode={item.DriverCode} driveVersion={item.Version} downloadFileName={item.FileName} downloadFilePath={item.FilePath} />),\n                pubDate: timezone(parseDate(item.CreateTime), 8),\n            }) as DataItem\n    );\n\n    return {\n        title: `${response.data.driverSerious[0].NodeCode} 驱动`,\n        item: items,\n        language: 'zh-CN',","sourceCodeStart":22,"sourceCodeEnd":58,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/lenovo/drive.tsx#L22-L58","documentation":"Thrown as InvalidParameterError by the Lenovo driver-download route when the Lenovo support API returns a non-200 statusCode for the given selName (product serial number / machine type). The Chinese message means 'invalid serial number, please check that your serial number is correct'. The route assumes any non-200 means the serial number is wrong.","triggerScenarios":"Submitting a mistyped or invalid Lenovo product serial number (e.g. PF3WRD2G is the example format). Also fires if the Lenovo API is temporarily unavailable (5xx) or rate-limits the request — the route conflates all non-200 responses with 'bad serial number'.","commonSituations":"User transposes digits in the serial number. User submits a consumer-model code to the business support endpoint or vice versa. Lenovo API has a transient outage and returns 500, but the user sees 'invalid serial number' which is misleading.","solutions":["Verify the serial number on the Lenovo support site directly: https://newsupport.lenovo.com.cn/ and search for it manually.","In the route, distinguish 4xx (likely bad input) from 5xx (server error) and throw InvalidParameterError only for 4xx.","Trim whitespace and uppercase the selName before submitting, since Lenovo serials are case-sensitive and whitespace-sensitive.","Include the actual statusCode in the error message for diagnosability."],"exampleFix":"// before\nif (response.statusCode !== 200) {\n    throw new InvalidParameterError('无效序列号, 请检查你的序列号是否正确.');\n}\n\n// after — distinguish bad input from server fault\nif (response.statusCode !== 200) {\n    if (response.statusCode >= 400 && response.statusCode < 500) {\n        throw new InvalidParameterError(`Invalid serial number '${selName}' (status ${response.statusCode}).`);\n    }\n    throw new Error(`Lenovo API error (status ${response.statusCode}); try again later.`);\n}","handlingStrategy":"validation","validationCode":"const selName = ctx.req.param('selName').trim().toUpperCase();\nif (!/^[A-Z0-9]{4,12}$/.test(selName)) {\n    throw new InvalidParameterError(`Serial number '${selName}' does not look valid (expected 4-12 alphanumeric chars).`);\n}\n// After fetch:\nif (response.statusCode !== 200) {\n    if (response.statusCode >= 500) throw new Error(`Lenovo API unavailable (status ${response.statusCode})`);\n    throw new InvalidParameterError(`Invalid serial number '${selName}' (status ${response.statusCode})`);\n}","typeGuard":null,"tryCatchPattern":"try {\n    const response = await ofetch(link);\n    if (response.statusCode !== 200) {\n        // distinguish bad input from server fault\n    }\n} catch (e) {\n    throw new Error(`Lenovo drive API unreachable: ${(e as Error).message}`, { cause: e });\n}","preventionTips":["Normalize the serial (trim + uppercase) before submission.","Distinguish 4xx (bad input) from 5xx (server fault) — only the former is truly 'invalid serial'.","Include the status code in the error for diagnosability.","Confirm the serial on the Lenovo support site before subscribing."],"tags":["validation","serial-number","lenovo","api","status-code"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}