DIYgod/RSSHub · error · InvalidParameterError

id not allowed

Error message

id not allowed

What it means

An `InvalidParameterError` from the zjol paper route when the `:id` path parameter is not one of the six allowed paper codes. The route only supports `zjrb`, `qjwb`, `msb`, `zjlnb`, `zjfzb`, `jnyb` (each mapping to a specific Zhejiang-region newspaper); any other value is rejected before fetching.

Source

Thrown at lib/routes/zjol/paper.ts:36

        supportBT: false,
        supportPodcast: false,
        supportScihub: false,
    },
    name: '浙报集团系列报刊',
    maintainers: ['nczitzk'],
    handler,
    description: `| 浙江日报 | 钱江晚报 | 美术报 | 浙江老年报 | 浙江法制报 | 江南游报 |
| -------- | -------- | ------ | ---------- | ---------- | -------- |
| zjrb     | qjwb     | msb    | zjlnb      | zjfzb      | jnyb     |`,
};

async function handler(ctx) {
    const id = ctx.req.param('id') ?? 'zjrb';
    const limit = ctx.req.query('limit') ? Number.parseInt(ctx.req.query('limit')) : 100;

    const allowedId = ['zjrb', 'qjwb', 'msb', 'zjlnb', 'zjfzb', 'jnyb'];
    if (!allowedId.includes(id)) {
        throw new InvalidParameterError('id not allowed');
    }

    const query = id === 'jnyb' ? 'map[name="PagePicMap"] area' : 'ul.main-ed-articlenav-list li a';

    const rootUrl = id === 'qjwb' ? 'http://qjwb.thehour.cn' : `https://${id}.zjol.com.cn`;
    let currentUrl = `${rootUrl}/paperindex.htm`;

    let response = await got({
        method: 'get',
        url: currentUrl,
    });

    const url = response.data.match(/URL=(.*)"/)[1];
    const pubDate = parseDate(url.match(/(\d{4}-\d{2}\/\d{2})/)[1], 'YYYY-MM/DD');

    currentUrl = `${rootUrl}/${url.replace(`/${url.split('/').pop()}`, '')}`;

    response = await got({

View on GitHub (pinned to bed535e087)

Solutions

  1. Use one of the documented codes exactly as listed (lowercase): `zjrb`, `qjwb`, `msb`, `zjlnb`, `zjfzb`, `jnyb`.
  2. Double-check the code against the route description table before requesting.
  3. If you need a paper not in the list, it is genuinely unsupported — request it upstream rather than retrying variants.

Example fix

// before — typo / unsupported code
// GET /zjol/paper/zjr  -> id not allowed
// after — exact allowed code
// GET /zjol/paper/zjrb
Defensive patterns

Strategy: validation

Validate before calling

const ALLOWED_ZJOL_IDS = new Set(['zjrb', 'qjwb', 'msb', 'zjlnb', 'zjfzb', 'jnyb']);
function normalizeZjolId(raw) {
    const id = String(raw).trim().toLowerCase();
    if (!ALLOWED_ZJOL_IDS.has(id)) {
        throw new Error(`id not allowed. Valid: ${[...ALLOWED_ZJOL_IDS].join(', ')}`);
    }
    return id;
}

Type guard

type ZjolPaperId = 'zjrb' | 'qjwb' | 'msb' | 'zjlnb' | 'zjfzb' | 'jnyb';
const ALLOWED: Set<ZjolPaperId> = new Set(['zjrb','qjwb','msb','zjlnb','zjfzb','jnyb']);
function isAllowedZjolId(id: string): id is ZjolPaperId {
    return ALLOWED.has(id.toLowerCase() as ZjolPaperId);
}

Prevention

When it happens

Trigger: The caller supplies an `id` outside the allow-list — a typo, an unsupported paper code, or an uppercase variant (the check is case-sensitive).

Common situations: User misspells a code (`zjr` instead of `zjrb`); uses uppercase (`ZJRB`); requests a paper the route doesn't cover; copies a paper name rather than its code (e.g. `浙江日报`).

Related errors


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