{"record":{"id":"5399915764d59f20","repo":"DIYgod/RSSHub","slug":"unknown-type-type","errorCode":null,"errorMessage":"Unknown type: ${type}","messagePattern":"Unknown type: (.+?)","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/routes/bse/index.ts","lineNumber":210,"sourceCode":"            items = data.data.content.map((item) => ({\n                title: item.title,\n                category: item.tags,\n                description: item.text,\n                link: `${rootUrl}${item.htmlUrl}`,\n                pubDate: timezone(parseDate(item.publishDate), 8),\n            }));\n            break;\n\n        case '/disclosureInfoController/zoneInfoResult':\n            items = data.listInfo.content.map((item) => ({\n                title: item.disclosureTitle,\n                link: `${rootUrl}${item.destFilePath}`,\n                pubDate: parseDate(item.pubDate.time),\n            }));\n            break;\n\n        default:\n            throw new Error(`Unknown type: ${type}`);\n    }\n\n    return {\n        title: `${nodes[category].title} - 北京证券交易所`,\n        link: `${rootUrl}${nodes[category].url}`,\n        item: items,\n        allowEmpty: true,\n    };\n}\n","sourceCodeStart":192,"sourceCodeEnd":220,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/bse/index.ts#L192-L220","documentation":"Generic Error from the default branch of the BSE (Beijing Stock Exchange) switch on `type`, where `type` is read from the internal `nodes` config table (nodes[category].type), not directly from user input. Reaching the default means a category in the nodes table was configured with a type value the switch does not handle — an internal invariant violation rather than a user typo.","triggerScenarios":"A category whose nodes entry has `.type` set to something other than '/info/listse' or '/disclosureInfoController/zoneInfoResult'. This happens when a maintainer adds a node entry with a new type slug but forgets to add the matching switch case.","commonSituations":"Maintainer edits the nodes table and adds a third type without extending the switch; a refactor renames a type slug in nodes but not in the switch; copy-paste of a node entry with an unhandled type.","solutions":["Add a switch case for the new type slug returned in the message (e.g. case '/someNewType': items = ...; break;).","Or correct the nodes[category].type value to one of the two handled slugs if it was mistyped.","Add a static check/test that every nodes[*].type has a corresponding switch case to catch this at build time."],"exampleFix":"// before\ndefault:\n    throw new Error(`Unknown type: ${type}`);\n// after (also validate category against nodes earlier so the message is actionable)\nif (!nodes[category]) {\n    throw new Error(`Unknown category: ${category}`);\n}\n// ... and ensure every nodes[*].type has a switch case","handlingStrategy":"validation","validationCode":"// Validate category against nodes first, and assert every nodes type is handled:\nif (!nodes[category]) throw new Error(`Unknown category: ${category}`);\nconst type = nodes[category].type;\nconst HANDLED = new Set(['/info/listse','/disclosureInfoController/zoneInfoResult']);\nif (!HANDLED.has(type)) throw new Error(`Unknown type: ${type}`);","typeGuard":"const HANDLED_TYPES = new Set(['/info/listse','/disclosureInfoController/zoneInfoResult']);\nconst isHandledType = (t: string): boolean => HANDLED_TYPES.has(t);","tryCatchPattern":null,"preventionTips":["Add a unit test asserting every nodes[*].type has a matching switch case.","When adding a node entry, add its switch case in the same commit.","Validate the user-supplied category is in nodes before reading .type."],"tags":["bse","internal-invariant","switch-default","config-table","maintainer"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}