DIYgod/RSSHub · error · Error

Invalid type: ${paramType}. Please refer to [the documentati

Error message

Invalid type: ${paramType}. Please refer to [the documentation](https://docs.rsshub.app/routes/other#${siteTitle}) for valid types.

What it means

Thrown by the 艾瑞咨询 (iresearch) report route when the `type` path/query param does not match any key in the `types` map and is not equal to any type's `label` or `value`. Plain `Error` (not `InvalidParameterError`). The message points users to the docs for the valid type list.

Source

Thrown at lib/routes/iresearch/report.ts:211

        label: '其他',
        value: '81',
    },
];

const defaultType = 1;
const siteTitle = '艾瑞咨询';

interface ReportItem extends DataItem {
    detailId?: string | number;
}

export const handler = async (ctx: Context): Promise<Data> => {
    const { type: paramType = defaultType, id: paramId = '' } = ctx.req.param();
    const limit = Number(ctx.req.query('limit') ?? '50');

    const typeObj = types?.[paramType] ?? Object.values(types).find((obj) => obj.label === paramType || obj.value === paramType);
    if (!typeObj) {
        throw new Error(`Invalid type: ${paramType}. Please refer to [the documentation](https://docs.rsshub.app/routes/other#${siteTitle}) for valid types.`);
    }

    const idObj = idOptions.find((option) => option.label === paramId || option.value === paramId);

    const type: number = typeObj.value;
    const id: string | undefined = idObj ? String(idObj.value) : undefined;

    const baseUrl = 'https://www.iresearch.com.cn';
    const imageBaseUrl = 'https://pic.iresearch.cn';
    const targetUrl: string = new URL(`report.shtml?type=${type}${id ? `&classId=${id}` : ''}`, baseUrl).href;
    const apiUrl: string = new URL(`api/${typeObj.slug}`, baseUrl).href;
    const apiDetailUrl: string = new URL(`api/${typeObj.detailSlug}`, baseUrl).href;

    const response = await ofetch(apiUrl, {
        query: {
            ...(id && {
                [typeObj.idKey]: id,
            }),

View on GitHub (pinned to bed535e087)

Solutions

  1. Consult the route's `description`/docs (https://docs.rsshub.app/routes/other#艾瑞咨询) for the current valid type list and use one of those values.
  2. If extending the route, add the new type to the `types` map in lib/routes/iresearch/report.ts.
  3. Use the type's `value` or `label` (both are accepted by the fallback lookup).

Example fix

// before: GET /iresearch/report/unknownType
// after: use a documented type, e.g.
GET /iresearch/report/industry
Defensive patterns

Strategy: validation

Validate before calling

const typeObj = types?.[paramType] ?? Object.values(types).find(o => o.label === paramType || o.value === paramType);
if (!typeObj) throw new InvalidParameterError(`Invalid type: ${paramType}. Valid: ${Object.keys(types).join(', ')}`);

Type guard

const isKnownType = (t: string) => Boolean(types[t]) || Object.values(types).some(o => o.label === t || String(o.value) === t);

Prevention

When it happens

Trigger: Request to the iresearch route with a `type` not present in the route's `types` config and not matching any `label`/`value`. E.g. `/iresearch/report/foo` where `foo` is unknown. Fires at report.ts:211 after both the direct-key and label/value fallback lookups fail.

Common situations: Typo in the type param; user references a type from outdated docs; the route's `types` map was refactored and a previously-valid type was removed.

Related errors


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