DIYgod/RSSHub · error · Error
dcpCode and clsNo cannot be used at the same time
Error message
dcpCode and clsNo cannot be used at the same time
What it means
The BUAA library new-book route parses the tail of the path as URLSearchParams and supports filtering by subject (dcpCode) OR by Chinese Library Classification (clsNo), but not both. The downstream API selects either a `/bysubject` or `/byclass` endpoint based on which filter is present, so supplying both is ambiguous and the handler throws a generic Error before building the URL.
Source
Thrown at lib/routes/buaa/lib/space/newbook.tsx:125
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportRadar: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
};
async function handler(ctx: Context): Promise<Data> {
const path = ctx.req.param('path');
const i = path!.indexOf('/');
const params = i === -1 ? '' : path!.slice(i + 1);
const searchParams = new URLSearchParams(params);
const dcpCode = searchParams.get('dcpCode'); // Filter by subject (discipline code)
const clsNo = searchParams.get('clsNo'); // Filter by class (Chinese Library Classification)
if (dcpCode && clsNo) {
throw new Error('dcpCode and clsNo cannot be used at the same time');
}
searchParams.set('pageSize', '100'); // Max page size. Any larger value will be ignored
searchParams.set('page', '1');
!dcpCode && !clsNo && searchParams.set('dcpCode', 'nolimit'); // No classification filter
const url = `https://space.lib.buaa.edu.cn/meta-local/opac/new/100/${clsNo ? 'byclass' : 'bysubject'}?${searchParams.toString()}`;
const { data } = await got(url);
const list = (data?.data?.dataList || []) as Book[];
const item = await Promise.all(list.map(async (item: Book) => await getItem(item)));
const res: Data = {
title: '北航图书馆 - 新书速递',
item,
description: '北京航空航天大学图书馆新书速递',
language: 'zh-CN' as Language,
link: 'https://space.lib.buaa.edu.cn/space/newBook',
author: '北京航空航天大学图书馆',
allowEmpty: true,
image: 'https://lib.buaa.edu.cn/apple-touch-icon.png',
};View on GitHub (pinned to bed535e087)
Solutions
- Supply at most one of dcpCode or clsNo in the path's query string.
- Omit both to get the unfiltered feed (the handler sets dcpCode=nolimit for you).
- Pick the scheme you want: dcpCode for subject/discipline, clsNo for CLC class.
Example fix
// before // /buaa/space/newbook/dcpCode=CS101/clsNo=TP311 // after (subject filter only) // /buaa/space/newbook/dcpCode=CS101
Defensive patterns
Strategy: validation
Validate before calling
const params = new URLSearchParams(queryTail);
const dcpCode = params.get('dcpCode');
const clsNo = params.get('clsNo');
if (dcpCode && clsNo) {
// reject early with a clear message before calling the route
throw new Error('Choose either dcpCode (subject) or clsNo (CLC class), not both.');
} Prevention
- Parse the query tail once and assert mutual exclusivity up front.
- Document that dcpCode and clsNo are alternatives, not combinable filters.
When it happens
Trigger: Calling the route with a path whose query string contains both `dcpCode` and `clsNo`, e.g. `/buaa/space/newbook/dcpCode=CS101/clsNo=TP311`.
Common situations: User concatenates two filter URLs thinking they combine; migrating from a bookmarked OPAC URL that carried both params; copy-paste of an exploratory search URL.
Related errors
- Invalid URL property: ${prop}
- Invalid Engine Value: ${engine}, please check your config.
- Invalid parameter brief. Please check the doc https://docs.r
- Invalid language code
- Invalid subdomain
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/5a63e88b4be77ff9.
Report an issue: GitHub.