{"record":{"id":"cb4bcb13336966ce","repo":"DIYgod/RSSHub","slug":"invalid-type","errorCode":null,"errorMessage":"Invalid type","messagePattern":"Invalid type","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"warning","filePath":"lib/routes/bitget/announcement.ts","lineNumber":64,"sourceCode":"        case 'new-listing':\n            reqBody.stationLetterType = '02';\n            break;\n\n        case 'latest-activities':\n            reqBody.stationLetterType = '01';\n            break;\n\n        case 'new-announcement':\n            reqBody.stationLetterType = '06';\n            break;\n\n        case 'all':\n            reqBody.stationLetterType = '0';\n            reqBody.excludeStationLetterType = '00';\n            break;\n\n        default:\n            throw new Error('Invalid type');\n    }\n\n    const response = (await cache.tryGet(\n        `bitget:announcement:${type}:${pageSize}:${lang}`,\n        async () => {\n            const result = await ofetch<BitgetResponse>(announcementApiUrl, {\n                method: 'POST',\n                body: reqBody,\n                headers,\n            });\n            if (result?.code !== '200') {\n                throw new Error('Failed to fetch announcements, error code: ' + result?.code);\n            }\n            return result;\n        },\n        config.cache.routeExpire,\n        false\n    )) as BitgetResponse;","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/bitget/announcement.ts#L46-L82","documentation":"Generic Error from the default branch of the bitget/announcement switch statement. The `type` path parameter must be one of new-listing, latest-activities, new-announcement, or all; anything else is rejected before the POST request body (stationLetterType) is assembled.","triggerScenarios":"A request to /bitget/announcement/:type/:lang? with a type value that matches none of the four switch cases, so the default branch fires before any network call.","commonSituations":"Typing the type slug (e.g. 'new-listings' instead of 'new-listing'); outdated client documentation; a category that Bitget renamed on their side.","solutions":["Use one of: new-listing, latest-activities, new-announcement, all.","Check the route's parameters/example in the latest source for the canonical slug list.","If Bitget added a new category, add a case mapping its stationLetterType and submit a PR."],"exampleFix":"// before\ndefault:\n    throw new Error('Invalid type');\n// after (enumerate valid values)\ndefault:\n    throw new Error(`Invalid type: ${type}. Valid: new-listing, latest-activities, new-announcement, all`);","handlingStrategy":"validation","validationCode":"const VALID_BITGET_TYPES = new Set(['new-listing','latest-activities','new-announcement','all']);\nif (!VALID_BITGET_TYPES.has(type)) {\n    throw new Error(`Invalid type '${type}'. Valid: ${[...VALID_BITGET_TYPES].join(', ')}`);\n}","typeGuard":"type BitgetType = 'new-listing'|'latest-activities'|'new-announcement'|'all';\nconst isBitgetType = (t: string): t is BitgetType =>\n    ['new-listing','latest-activities','new-announcement','all'].includes(t);","tryCatchPattern":null,"preventionTips":["Document the four valid slugs in the route parameters.","If Bitget adds a category, add the case + stationLetterType together to avoid the default."],"tags":["bitget","validation","path-parameter","enum","switch-default"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}