{"record":{"id":"36daf78f257d37bc","repo":"DIYgod/RSSHub","slug":"id-not-allowed","errorCode":null,"errorMessage":"id not allowed","messagePattern":"id not allowed","errorType":"validation","errorClass":"InvalidParameterError","httpStatus":null,"severity":"error","filePath":"lib/routes/zjol/paper.ts","lineNumber":36,"sourceCode":"        supportBT: false,\n        supportPodcast: false,\n        supportScihub: false,\n    },\n    name: '浙报集团系列报刊',\n    maintainers: ['nczitzk'],\n    handler,\n    description: `| 浙江日报 | 钱江晚报 | 美术报 | 浙江老年报 | 浙江法制报 | 江南游报 |\n| -------- | -------- | ------ | ---------- | ---------- | -------- |\n| zjrb     | qjwb     | msb    | zjlnb      | zjfzb      | jnyb     |`,\n};\n\nasync function handler(ctx) {\n    const id = ctx.req.param('id') ?? 'zjrb';\n    const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 100;\n\n    const allowedId = ['zjrb', 'qjwb', 'msb', 'zjlnb', 'zjfzb', 'jnyb'];\n    if (!allowedId.includes(id)) {\n        throw new InvalidParameterError('id not allowed');\n    }\n\n    const query = id === 'jnyb' ? 'map[name=\"PagePicMap\"] area' : 'ul.main-ed-articlenav-list li a';\n\n    const rootUrl = id === 'qjwb' ? 'http://qjwb.thehour.cn' : `https://${id}.zjol.com.cn`;\n    let currentUrl = `${rootUrl}/paperindex.htm`;\n\n    let response = await got({\n        method: 'get',\n        url: currentUrl,\n    });\n\n    const url = response.data.match(/URL=(.*)\"/)[1];\n    const pubDate = parseDate(url.match(/(\\d{4}-\\d{2}\\/\\d{2})/)[1], 'YYYY-MM/DD');\n\n    currentUrl = `${rootUrl}/${url.replace(`/${url.split('/').pop()}`, '')}`;\n\n    response = await got({","sourceCodeStart":18,"sourceCodeEnd":54,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/zjol/paper.ts#L18-L54","documentation":"An `InvalidParameterError` from the zjol paper route when the `:id` path parameter is not one of the six allowed paper codes. The route only supports `zjrb`, `qjwb`, `msb`, `zjlnb`, `zjfzb`, `jnyb` (each mapping to a specific Zhejiang-region newspaper); any other value is rejected before fetching.","triggerScenarios":"The caller supplies an `id` outside the allow-list — a typo, an unsupported paper code, or an uppercase variant (the check is case-sensitive).","commonSituations":"User misspells a code (`zjr` instead of `zjrb`); uses uppercase (`ZJRB`); requests a paper the route doesn't cover; copies a paper name rather than its code (e.g. `浙江日报`).","solutions":["Use one of the documented codes exactly as listed (lowercase): `zjrb`, `qjwb`, `msb`, `zjlnb`, `zjfzb`, `jnyb`.","Double-check the code against the route description table before requesting.","If you need a paper not in the list, it is genuinely unsupported — request it upstream rather than retrying variants."],"exampleFix":"// before — typo / unsupported code\n// GET /zjol/paper/zjr  -> id not allowed\n// after — exact allowed code\n// GET /zjol/paper/zjrb","handlingStrategy":"validation","validationCode":"const ALLOWED_ZJOL_IDS = new Set(['zjrb', 'qjwb', 'msb', 'zjlnb', 'zjfzb', 'jnyb']);\nfunction normalizeZjolId(raw) {\n    const id = String(raw).trim().toLowerCase();\n    if (!ALLOWED_ZJOL_IDS.has(id)) {\n        throw new Error(`id not allowed. Valid: ${[...ALLOWED_ZJOL_IDS].join(', ')}`);\n    }\n    return id;\n}","typeGuard":"type ZjolPaperId = 'zjrb' | 'qjwb' | 'msb' | 'zjlnb' | 'zjfzb' | 'jnyb';\nconst ALLOWED: Set<ZjolPaperId> = new Set(['zjrb','qjwb','msb','zjlnb','zjfzb','jnyb']);\nfunction isAllowedZjolId(id: string): id is ZjolPaperId {\n    return ALLOWED.has(id.toLowerCase() as ZjolPaperId);\n}","tryCatchPattern":null,"preventionTips":["Normalize the id to lowercase and validate against the allow-list before the request.","Surface the list of valid codes in the error so callers self-correct.","Treat case-insensitively to avoid spurious rejections of uppercase input."],"tags":["zjol","validation","route-parameter","allow-list","invalid-parameter"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}