DIYgod/RSSHub · error · InvalidParameterError

Invalid district

Error message

Invalid district

What it means

An `InvalidParameterError` at lib/routes/wellcee/rent.tsx:70 when the optional `:district` path parameter is provided but does not match any `name` in the district list returned by `getDistricts(cityInfo.id)` for the given city. Only evaluated when `district` is non-empty. Districts are Chinese-language names fetched dynamically per-city.

Source

Thrown at lib/routes/wellcee/rent.tsx:70

    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: [],
            timeTypeIds: [],
            price: [],
            tagTypeIds: [],
            cityId: cityInfo.id,
            lang: 1,
            pn: 1,
        },
    });

View on GitHub (pinned to bed535e087)

Solutions

  1. Omit the `:district` parameter entirely to get all listings for the city.
  2. Inspect the Wellcee website for the target city to find the exact Chinese district name used internally.
  3. Verify getDistricts() in ./utils still returns the expected `[{ name, id, ... }]` shape.
Defensive patterns

Strategy: validation

Validate before calling

const districts = await getDistricts(cityInfo.id);
const validDistrictNames = districts.map((d) => d.name);
if (district && !validDistrictNames.includes(district)) {
    throw new InvalidParameterError(`Invalid district. Supported: ${validDistrictNames.join(', ')}`);
}

Type guard

const isValidWellceeDistrict = (district: string, districts: Array<{ name: string }>): boolean =>
    districts.some((d) => d.name === district);

Prevention

When it happens

Trigger: Passing a valid city but a district that doesn't belong to it (e.g. a Beijing district under 上海); passing the English district name; the district was renamed in Wellcee's database; URL-encoding issues with Chinese characters in the path.

Common situations: User enters English district name; user mixes up which districts belong to which city; district list API shape changed.

Related errors


AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12). Data as JSON: /api/errors/9352713a608ec8ba. Report an issue: GitHub.