{"record":{"id":"0c7bb2715e5ae011","repo":"DIYgod/RSSHub","slug":"invalid-channel-id-id","errorCode":null,"errorMessage":"Invalid channel Id: ${id}","messagePattern":"Invalid channel Id: (.+?)","errorType":"validation","errorClass":"InvalidParameterError","httpStatus":null,"severity":"error","filePath":"lib/routes/gov/csrc/csrc.ts","lineNumber":27,"sourceCode":"    const { id = 'c101972' } = ctx.req.param();\n    const limit = ctx.req.query('limit') ? Number(ctx.req.query('limit')) : 50;\n\n    const rootUrl = 'http://www.csrc.gov.cn';\n    const apiUrl = new URL('getLocalList', rootUrl).href;\n    const currentUrl = new URL(`/csrc/${id}/zfxxgk_zdgk.shtml`, rootUrl).href;\n\n    const { data: channelResponse } = await got(apiUrl, {\n        searchParams: {\n            channelCode: id,\n        },\n    });\n\n    const channel = channelResponse.results.channelLevel.find((channel) => channel.channelCode === id);\n    const channelId = channel?.channelId ?? undefined;\n    const channelName = channel?.channelName ?? undefined;\n\n    if (!channelId) {\n        throw new InvalidParameterError(`Invalid channel Id: ${id}`);\n    }\n\n    const apiSearchUrl = new URL(`searchList/${channelId}`, rootUrl).href;\n\n    const { data: response } = await got(apiSearchUrl, {\n        searchParams: {\n            _isAgg: true,\n            _isJson: true,\n            _pageSize: limit,\n        },\n    });\n\n    const items = response.data.results.slice(0, limit).map((item) => {\n        const title = item.title;\n        const description = item.contentHtml;\n        const enclosure = item.resList?.[0] ?? undefined;\n\n        return {","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/gov/csrc/csrc.ts#L9-L45","documentation":"Thrown as an InvalidParameterError by the CSRC (China Securities Regulatory Commission) route when the provided channel code (id) is not found in the API's channelLevel response. The route calls getLocalList with channelCode=id, then searches the returned channelLevel array for a matching channelCode. If no match is found, channelId is undefined.","triggerScenarios":"A request to /gov/csrc/zfxxgk_zdgk/:id where :id (default 'c101972') is not a valid channel code in the CSRC system. The API returns results.channelLevel but none of the entries have a channelCode matching the provided id.","commonSituations":"Typo in the channel code (e.g., 'c10179' instead of 'c101793'); using an outdated channel code that was removed from the CSRC site; guessing a code format; the channel code format changed on the CSRC site.","solutions":["Use a valid channel code from the route description table in the source (e.g., c101971 for administrative penalties, c101972 for market ban decisions)","Omit the id parameter to use the default (c101972)","Browse www.csrc.gov.cn, navigate to the desired channel, and extract the code from the URL (the part between /csrc/ and /zfxxgk_zdgk.shtml)"],"exampleFix":"// before\nconst channel = channelResponse.results.channelLevel.find((channel) => channel.channelCode === id);\nconst channelId = channel?.channelId ?? undefined;\nif (!channelId) {\n    throw new InvalidParameterError(`Invalid channel Id: ${id}`);\n}\n\n// This is already well-structured. To improve diagnostics:\nif (!channelId) {\n    throw new InvalidParameterError(`Invalid channel Id: ${id}. Valid codes are listed at /gov/csrc/zfxxgk_zdgk route documentation.`);\n}","handlingStrategy":"validation","validationCode":"const VALID_CHANNEL_IDS = ['c101972', 'c101971', 'c101793', 'c101951', 'c101985', /* ... see route description */];\nconst { id = 'c101972' } = ctx.req.param();\n// Best approach: let the API validate. The InvalidParameterError is the API's response.\n// For client-side validation, cross-reference the channel code format:\nif (!/^c\\d{6}$/.test(id)) {\n    throw new InvalidParameterError(`Channel ID must match format cXXXXXX, got: ${id}`);\n}","typeGuard":"function isValidChannelId(id: string): boolean {\n    return /^c\\d{6}$/.test(id);\n}","tryCatchPattern":null,"preventionTips":["Use the default (c101972) when unsure","Extract channel codes from the CSRC website URL path","Refer to the extensive channel ID table in the route description"],"tags":["validation","invalid-parameter","api","government"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}