{"record":{"id":"42257d6df04473e8","repo":"DIYgod/RSSHub","slug":"type-is-not-supported","errorCode":null,"errorMessage":"${type} is not supported","messagePattern":"(.+?) is not supported","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"lib/routes/binance/announcement.ts","lineNumber":72,"sourceCode":"    const pageSize = Number.isNaN(limit) || limit <= 0 ? 20 : limit;\n\n    let type = rawType;\n    let language = normalizeLanguage(rawLang);\n\n    if (!rawLang && rawType && isLanguageCode(rawType)) {\n        language = normalizeLanguage(rawType);\n        type = undefined;\n    }\n\n    if (type === 'all') {\n        type = undefined;\n    }\n\n    let catalogId: number | undefined;\n    if (type) {\n        const mappedCatalogId = TYPE_CATALOG_ID_MAP[type];\n        if (!mappedCatalogId) {\n            throw new Error(`${type} is not supported`);\n        }\n        catalogId = mappedCatalogId;\n    }\n\n    const pageUrl = `${baseUrl}/${language}/messages/v2/group/announcement`;\n    const listUrl = new URL(`${baseUrl}/bapi/apex/v1/public/apex/cms/article/list/query`);\n    listUrl.searchParams.set('type', '1');\n    listUrl.searchParams.set('pageNo', '1');\n    listUrl.searchParams.set('pageSize', String(pageSize));\n    if (catalogId) {\n        listUrl.searchParams.set('catalogId', String(catalogId));\n    }\n\n    const headers = {\n        Referer: pageUrl,\n        'Accept-Language': language,\n        'User-Agent': config.trueUA,\n        lang: language,","sourceCodeStart":54,"sourceCodeEnd":90,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/binance/announcement.ts#L54-L90","documentation":"Generic Error thrown when the `type` path parameter of /binance/announcement/:type/:lang? does not resolve to a key in TYPE_CATALOG_ID_MAP (the fixed allow-list of 8 Binance announcement categories). It guards the catalogId lookup so an unmapped slug never produces a malformed API call.","triggerScenarios":"A caller passes a type slug not present in TYPE_CATALOG_ID_MAP (e.g. a typo or a category Binance renamed), and the value is not 'all' and not detected as a language code. The mappedCatalogId lookup returns undefined and the guard fires.","commonSituations":"Typing the category slug incorrectly (e.g. 'new-listing' vs 'new-cryptocurrency-listing'); Binance adding a new category whose slug is not yet mapped; using an old documentation example whose slug was renamed.","solutions":["Use a slug from TYPE_CATALOG_ID_MAP: new-cryptocurrency-listing, latest-binance-news, latest-activities, new-fiat-listings, api-updates, crypto-airdrop, wallet-maintenance-updates, delisting.","Use 'all' (or omit type) to fetch every category without a catalogId filter.","If the category genuinely exists on Binance, add its slug and catalogId to TYPE_CATALOG_ID_MAP and submit a PR."],"exampleFix":"// before\nthrow new Error(`${type} is not supported`);\n// after (list the valid slugs in the message)\nconst valid = Object.keys(TYPE_CATALOG_ID_MAP).join(', ');\nthrow new Error(`${type} is not supported. Valid types: all, ${valid}`);","handlingStrategy":"validation","validationCode":"const VALID_TYPES = new Set(['all', ...Object.keys(TYPE_CATALOG_ID_MAP)]);\nif (type && !VALID_TYPES.has(type)) {\n    throw new Error(`${type} is not supported. Valid: ${[...VALID_TYPES].join(', ')}`);\n}","typeGuard":"const isSupportedType = (t: string | undefined): boolean =>\n    !t || t === 'all' || Object.hasOwn(TYPE_CATALOG_ID_MAP, t);","tryCatchPattern":null,"preventionTips":["Keep the route's parameter description in sync with TYPE_CATALOG_ID_MAP keys.","When Binance renames a category, add an alias mapping rather than leaving a dead slug."],"tags":["binance","validation","path-parameter","enum"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}