DIYgod/RSSHub · error · Error
Unknown path[1]: ${path[1]}
Error message
Unknown path[1]: ${path[1]} What it means
Thrown by the Maoming government portal route in the default case of a switch statement on path[1]. The route splits the incoming sub-path into segments and dispatches based on the second segment (path[1]), which identifies the specific government bureau/department. If no case matches, the default throws with the unrecognized path[1] value.
Source
Thrown at lib/routes/gov/maoming/maoming.ts:398
: '#main21l_main_dkc .hei[href*="cgj.maoming.gov.cn"], #main21l_main_dkc .hei[href*="mp.weixin.qq.com"]';
list_include = 'all';
title_element = 'td[background="/global/rlyelen_line04.gif"] > table:nth-child(1) > tbody > tr:nth-child(2)';
description_element = 'td[background="/global/rlyelen_line04.gif"] > table:nth-child(1) > tbody > tr:nth-child(4)';
authorisme = '茂名市城市管理和综合执法局';
pubDate_element = 'td[background="/global/rlyelen_line04.gif"] > table:nth-child(1) > tbody > tr:nth-child(3)';
pubDate_match = '发表时间:(.*)';
break;
case 'xzfw':
defaultPath = 'zcjd/';
list_element = '#lblListInfo a';
title_element = '.HTitle';
description_element = '#mmhygs';
authorisme = '茂名市政务服务网';
pubDate_element = '.HTime';
pubDate_match = '发布日期:(.*) 点击率';
break;
default:
throw new Error(`Unknown path[1]: ${path[1]}`);
}
const info = {
pathstartat,
defaultPath,
list_element,
list_include,
title_element,
title_match,
description_element,
authorisme,
pubDate_element,
pubDate_match,
// pubDate_format,
};
return await gdgov(info, ctx);
}
View on GitHub (pinned to bed535e087)
Solutions
- Refer to the switch cases in maoming.ts (lines 39-398) for the complete list of supported bureau codes
- Ensure the path follows the format documented in the route description: the domain prefix (e.g., 'www', 'mmny') followed by the URL path
- If the bureau should be supported, add a new case to the switch statement with the appropriate selectors
Example fix
// before
default:
throw new Error(`Unknown path[1]: ${path[1]}`);
// after (use InvalidParameterError with list of valid values)
import InvalidParameterError from '@/errors/types/invalid-parameter';
// ...
default:
throw new InvalidParameterError(`Unknown bureau code '${path[1]}'. Supported: www, mmny, mmswj, wgxj, wsjkj, scj, ajj, cgj, xzfw`); Defensive patterns
Strategy: validation
Validate before calling
const KNOWN_BUREAUS = new Set(['www', 'mmny', 'mmswj', 'wgxj', 'wsjkj', 'scj', 'ajj', 'cgj', 'xzfw' /* ... */]);
const path = getSubPath(ctx).split('/').filter(Boolean);
if (path.length < 2 || !KNOWN_BUREAUS.has(path[1])) {
throw new InvalidParameterError(`Unknown bureau '${path[1]}'. Check supported bureaus in the route source.`);
} Prevention
- Refer to the switch cases in maoming.ts for the authoritative list of bureau codes
- Follow the path format documented in the route description
- The first path segment is the domain prefix, the second identifies the bureau
When it happens
Trigger: A request to /gov/maoming/<path> where the second path segment doesn't match any known bureau code (www, mmny, mmswj, wgxj, wsjkj, scj, ajj, cgj, xzfw, etc.). The path is extracted via getSubPath(ctx), split by '/', and filtered for empty strings.
Common situations: Navigating to a Maoming government subdomain/department that isn't yet supported; typo in the bureau code; the path structure changed; using a department abbreviation that doesn't match the switch cases.
Related errors
- Unknown category: ${ctx.req.param('category')}
- Bad timeRange range. See <a href="https://docs.rsshub.app/ro
- Bad parameter. See <a href="https://docs.rsshub.app/routes/g
- Invalid city
- Invalid channel name
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/f0d6d01a034eaa36.
Report an issue: GitHub.