DIYgod/RSSHub · warning · Error
Invalid type
Error message
Invalid type
What it means
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.
Source
Thrown at lib/routes/bitget/announcement.ts:64
case 'new-listing':
reqBody.stationLetterType = '02';
break;
case 'latest-activities':
reqBody.stationLetterType = '01';
break;
case 'new-announcement':
reqBody.stationLetterType = '06';
break;
case 'all':
reqBody.stationLetterType = '0';
reqBody.excludeStationLetterType = '00';
break;
default:
throw new Error('Invalid type');
}
const response = (await cache.tryGet(
`bitget:announcement:${type}:${pageSize}:${lang}`,
async () => {
const result = await ofetch<BitgetResponse>(announcementApiUrl, {
method: 'POST',
body: reqBody,
headers,
});
if (result?.code !== '200') {
throw new Error('Failed to fetch announcements, error code: ' + result?.code);
}
return result;
},
config.cache.routeExpire,
false
)) as BitgetResponse;View on GitHub (pinned to bed535e087)
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.
Example fix
// before
default:
throw new Error('Invalid type');
// after (enumerate valid values)
default:
throw new Error(`Invalid type: ${type}. Valid: new-listing, latest-activities, new-announcement, all`); Defensive patterns
Strategy: validation
Validate before calling
const VALID_BITGET_TYPES = new Set(['new-listing','latest-activities','new-announcement','all']);
if (!VALID_BITGET_TYPES.has(type)) {
throw new Error(`Invalid type '${type}'. Valid: ${[...VALID_BITGET_TYPES].join(', ')}`);
} Type guard
type BitgetType = 'new-listing'|'latest-activities'|'new-announcement'|'all';
const isBitgetType = (t: string): t is BitgetType =>
['new-listing','latest-activities','new-announcement','all'].includes(t); Prevention
- Document the four valid slugs in the route parameters.
- If Bitget adds a category, add the case + stationLetterType together to avoid the default.
When it happens
Trigger: 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.
Common situations: Typing the type slug (e.g. 'new-listings' instead of 'new-listing'); outdated client documentation; a category that Bitget renamed on their side.
Related errors
- ${type} is not supported
- Invalid category
- Unsupported filter type "${filter}", please choose from { ${
- Bad timeRange range. See <a href="https://docs.rsshub.app/ro
- This category does not exist. Please refer to the documentat
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/cb4bcb13336966ce.
Report an issue: GitHub.