DIYgod/RSSHub · error · InvalidParameterError
Unsupported region: ${region}
Error message
Unsupported region: ${region} What it means
InvalidParameterError thrown by the Yahoo news listid handler when ctx.req.param('region') is not 'hk' or 'tw'. The listId-based endpoint is only implemented for Hong Kong and Taiwan Yahoo (the markets whose archive uses stream listIds), so other regions are rejected before getList is called.
Source
Thrown at lib/routes/yahoo/news/listid.ts:46
maintainers: ['TonyRL', 'williamgateszhao', 'tpnonthealps'],
handler,
description: `| 合作媒體 (\`HK\`) | \`:listId\` |
| --------------- | -------------------------------------- |
| 東方日報 | \`33ddd580-0ab3-11e8-bfe1-4b555fb1e429\` |
| now\\.com | \`01b4d760-0ab4-11e8-af3a-54037d3dced3\` |
| am730 | \`c4842090-0ab2-11e8-af7f-041a72ce7398\` |
| BBC | \`4d3fc9a0-fac8-11e9-87f2-564ca250983e\` |
| 信報財經新聞 | \`5a8a0aa0-0ab3-11e8-b3dc-d990c79d6cb1\` |
| 香港電台 | \`b4bfc2d0-0ab3-11e8-bf9f-c888fc09923f\` |
| 法新社 | \`1cc44280-facb-11e9-ad7c-f3ba971275c8\` |
| Bloomberg | \`40023670-facc-11e9-9dde-9175ff306602\` |
| 香港動物報 | \`6058fa9c-d74d-487a-8b49-aa99a2a2978e\` |`,
};
async function handler(ctx) {
const { region, listId } = ctx.req.param();
if (!['hk', 'tw'].includes(region)) {
throw new InvalidParameterError(`Unsupported region: ${region}`);
}
const response = await getList(region, listId);
// console.log('Response:', response.stream_items);
// console.log('Type of response:', typeof response.stream_items);
// console.log('Is response an array?', Array.isArray(response.stream_items));
const list = parseList(region, response.stream_items);
const items = await Promise.all(list.map((item) => parseItem(item)));
const author = items[0].author;
const atIndex = author?.indexOf('@'); // fing '@'
const source = atIndex === -1 ? author : author?.slice(atIndex + 1).trim();
// console.log(source);
return {
title: `Yahoo 新聞 - ${source ?? ''}`,View on GitHub (pinned to bed535e087)
Solutions
- Use 'hk' or 'tw' as the region segment for the listid route.
- For other regions, use the main /yahoo/news/:region/:category route instead.
Defensive patterns
Strategy: validation
Validate before calling
function requireListidRegion(region: string) {
if (!['hk', 'tw'].includes(region)) {
throw new InvalidParameterError(`Unsupported region: ${region}. The listid route supports only hk and tw.`);
}
} Type guard
function isListidRegion(value: string): value is 'hk' | 'tw' {
return value === 'hk' || value === 'tw';
} Prevention
- Use the general /yahoo/news route for non-hk/tw regions.
- Document clearly that listId is a HK/TW-only concept.
When it happens
Trigger: A request to /yahoo/news/listid/:region/:listId where region is e.g. 'au', 'sg', 'us', or any non-hk/tw value. The destructure `const { region, listId } = ctx.req.param()` reads both, then the includes() guard fires.
Common situations: Caller used the generic /yahoo/news region list on this listid-specific route; assumed listId works for all Yahoo regions; typo.
Related errors
- Unknown region: ${region}
- Unknown category for ${region}: ${category}
- Unknown region: ${region}
- Unknown region: ${region}
- Invalid language parameter. Use "en" or "zh".
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/5ae8ea8fea561403.
Report an issue: GitHub.