DIYgod/RSSHub · error · InvalidParameterError
Invalid sort type: ${sortType}
Error message
Invalid sort type: ${sortType} What it means
Acfun article feed accepts exactly three sortType values — createTime, lastCommentTime, hotScore — checked against a Set. Anything else is rejected before the API call.
Source
Thrown at lib/routes/acfun/article.ts:101
| ---------- | ---- | -------- | ---- | -------- | -------- |
| 184 | 110 | 73 | 164 | 74 | 75 |
| 最新发表 | 最新动态 | 最热文章 |
| ---------- | --------------- | -------- |
| createTime | lastCommentTime | hotScore |
| 时间不限 | 24 小时 | 三天 | 一周 | 一个月 |
| -------- | ------- | -------- | ------- | -------- |
| all | oneDay | threeDay | oneWeek | oneMonth |`,
};
async function handler(ctx) {
const { categoryId, sortType = 'createTime', timeRange = 'all' } = ctx.req.param();
if (!Object.hasOwn(categoryMap, categoryId)) {
throw new InvalidParameterError(`Invalid category Id: ${categoryId}`);
}
if (!sortTypeEnum.has(sortType)) {
throw new InvalidParameterError(`Invalid sort type: ${sortType}`);
}
if (!timeRangeEnum.has(timeRange)) {
throw new InvalidParameterError(`Invalid time range: ${timeRange}`);
}
const url = `${baseUrl}/v/list${categoryId}/index.htm`;
const response = await got.post(
`${baseUrl}/rest/pc-direct/article/feed?cursor=first_page&onlyOriginal=false&limit=10&sortType=${sortType}&timeRange=${sortType === 'hotScore' ? timeRange : 'all'}&${categoryMap[categoryId].realmId}`,
{
headers: {
referer: url,
},
}
);
const list = response.data.data.map((item) => ({
title: item.title,
link: `${baseUrl}/a/ac${item.articleId}`,View on GitHub (pinned to bed535e087)
Solutions
- Use one of: createTime, lastCommentTime, hotScore.
- Omit sortType to accept the default 'createTime'.
Example fix
// before /acfun/article/110/最新发表 // after /acfun/article/110/createTime
Defensive patterns
Strategy: validation
Validate before calling
const ACFUN_SORT = new Set(['createTime','lastCommentTime','hotScore']);
function validAcfunSort(s) {
return ACFUN_SORT.has(s);
} Type guard
function isAcfunSortType(s): s is 'createTime'|'lastCommentTime'|'hotScore' {
return ['createTime','lastCommentTime','hotScore'].includes(s);
} Prevention
- Match the literal English slug, case-sensitive.
- Omit sortType to accept the createTime default rather than guessing.
- Avoid passing localized labels ('最新发表') through to the route.
When it happens
Trigger: Calling /acfun/article/<id>/<sortType> with sortType not in {createTime, lastCommentTime, hotScore} (case-sensitive).
Common situations: Passing a translated label ('最新发表'); typo ('creatTime'); using an Acfun-internal sort code instead of the slug.
Related errors
- Bad timeRange range. See <a href="https://docs.rsshub.app/ro
- This category does not exist. Please refer to the documentat
- Invalid category Id: ${categoryId}
- Invalid time range: ${timeRange}
- This type does not exist. Please refer to the documentation
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/f823193e52da8eb8.
Report an issue: GitHub.