DIYgod/RSSHub · error · InvalidParameterError
Invalid city
Error message
Invalid city
What it means
An `InvalidParameterError` at lib/routes/wellcee/rent.tsx:62 when the `:city` path parameter does not match any `chCityName` in the list fetched by `getCitys()`. Wellcee's city list contains Chinese-language city names (e.g. 北京, 上海), so the match is exact string equality against Chinese names. The supported set is discoverable via the `/wellcee/support-city` route.
Source
Thrown at lib/routes/wellcee/rent.tsx:62
path: '/rent/:city/:district?',
example: '/wellcee/rent/北京',
parameters: {
city: '城市',
district: '地区',
},
name: '租房信息',
maintainers: ['TonyRL'],
handler,
url: 'www.wellcee.com',
description: '支持的城市可以通过 [/wellcee/support-city](https://rsshub.app/wellcee/support-city) 获取',
};
async function handler(ctx: Context) {
const { city, district = '' } = ctx.req.param();
const citys = await getCitys();
const cityInfo = citys.find((item) => item.chCityName === city);
if (!cityInfo) {
throw new InvalidParameterError('Invalid city');
}
let districtInfo: District | undefined;
if (district) {
const districts = await getDistricts(cityInfo.id);
const d = districts.find((item) => item.name === district);
if (!d) {
throw new InvalidParameterError('Invalid district');
}
districtInfo = d;
}
const response = await ofetch(`${baseUrl}/api/house/filter`, {
method: 'POST',
body: {
districtIds: districtInfo?.id ? [districtInfo.id] : [],
subways: [],
rentTypeIds: [],View on GitHub (pinned to bed535e087)
Solutions
- Call the `/wellcee/support-city` route first to see the exact supported Chinese city names.
- Use the exact `chCityName` value (Chinese characters) as the `:city` path segment.
- If no cities match at all, check whether the getCitys() utility in ./utils still hits a valid Wellcee API endpoint.
Defensive patterns
Strategy: validation
Validate before calling
const citys = await getCitys();
const validCityNames = citys.map((c) => c.chCityName);
if (!validCityNames.includes(city)) {
throw new InvalidParameterError(`Invalid city. Supported: ${validCityNames.join(', ')}`);
} Type guard
const isValidWellceeCity = (city: string, citys: Array<{ chCityName: string }>): boolean =>
citys.some((c) => c.chCityName === city); Prevention
- Always use the exact Chinese city name from the /wellcee/support-city route.
- Do not use English city names or Pinyin.
- Check for trailing whitespace or URL-encoding when passing Chinese characters in the path.
When it happens
Trigger: Passing 'Beijing' instead of '北京'; passing a city Wellcee does not operate in; trailing whitespace or URL-encoding in the city parameter; the getCitys() API changed and returns an unexpected shape so the find always fails.
Common situations: User enters the English city name; user guesses a city not in Wellcee's coverage; the support-city list changed.
Related errors
- Invalid district
- 未找到 ${placeName} 的疫情数据,请检查输入的省市名称是否正确
- Invalid parameter brief. Please check the doc https://docs.r
- Unknown category: ${category}. Valid: ${Object.keys(category
- Category "${categorySlug}" not found
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/b42045b90a7cfc0a.
Report an issue: GitHub.