DIYgod/RSSHub · error · InvalidParameterError
Invalid isekai ranking type: ${type}
Error message
Invalid isekai ranking type: ${type} What it means
Thrown by parseIsekaiRankingType (syosetu/ranking-isekai.ts:22) as an InvalidParameterError when the isekai ranking `type` string (format period_category_novelType) has ANY component that is not a valid enum value. Valid periods (RankingPeriod): daily, weekly, monthly, quarter, yearly, total. Valid categories (IsekaiCategory): '1' (Renai), '2' (Fantasy), 'o' (Other). Valid novelTypes (NovelType): total, t, r, er. novelType defaults to 'total' if omitted. Reached via /syosetu/ranking/isekai/<type>.
Source
Thrown at lib/routes/syosetu/ranking-isekai.ts:22
import InvalidParameterError from '@/errors/types/invalid-parameter';
import type { Data, DataItem } from '@/types';
import { renderDescription } from './templates/description';
import { IsekaiCategory, isekaiCategoryToJapanese, NovelType, novelTypeToJapanese, periodToJapanese, periodToOrder, periodToPointField, RankingPeriod } from './types/ranking';
type Join<T extends string | number> = `${T}-${T}` | `${T}`;
export function parseIsekaiRankingType(type: string): { period: RankingPeriod; category: IsekaiCategory; novelType: NovelType } {
const [periodStr, categoryStr, novelTypeStr = NovelType.TOTAL] = type.split('_', 3);
const period = periodStr as RankingPeriod;
const category = categoryStr as IsekaiCategory;
const novelType = novelTypeStr as NovelType;
const isValid = [Object.values(RankingPeriod).includes(period), Object.values(IsekaiCategory).includes(category), Object.values(NovelType).includes(novelType)].every(Boolean);
if (!isValid) {
throw new InvalidParameterError(`Invalid isekai ranking type: ${type}`);
}
return { period, category, novelType };
}
function getIsekaiSearchParams(period, category, novelType, limit): SearchParams {
const searchParams: SearchParams = {
order: periodToOrder[period],
gzip: 5,
// Request 20% more items to compensate for potential duplicates between tensei/tenni
lim: Math.ceil((limit / 2) * 1.2),
};
if (novelType !== NovelType.TOTAL) {
searchParams.type = novelType;
}
switch (category) {View on GitHub (pinned to bed535e087)
Solutions
- Use the exact format <period>_<category>_<novelType> with only valid values, e.g. daily_2_total or weekly_1_r.
- Remember novelType is optional and defaults to total, so daily_2 is also valid.
- Pick a known-good value from the route's parameters.type.options (auto-generated from the enums).
Example fix
// before GET /syosetu/ranking/isekai/daily_3_total // after (category must be 1, 2, or o) GET /syosetu/ranking/isekai/daily_2_total
Defensive patterns
Strategy: validation
Validate before calling
import { RankingPeriod, NovelType, IsekaiCategory } from './types/ranking';
const PERIODS = Object.values(RankingPeriod);
const CATEGORIES = Object.values(IsekaiCategory);
const NOVEL_TYPES = Object.values(NovelType);
function isValidIsekaiType(type: string): boolean {
const [p, c, n = NovelType.TOTAL] = type.split('_', 3);
return PERIODS.includes(p as RankingPeriod)
&& CATEGORIES.includes(c as IsekaiCategory)
&& NOVEL_TYPES.includes(n as NovelType);
} Type guard
function isIsekaiRankingType(type: string): boolean {
const [p, c, n = 'total'] = type.split('_', 3);
return ['daily','weekly','monthly','quarter','yearly','total'].includes(p)
&& ['1','2','o'].includes(c)
&& ['total','t','r','er'].includes(n);
} Prevention
- Use the format <period>_<category>_<novelType> with category in {1, 2, o}.
- Pick values from the route's parameters.type.options table rather than hand-typing.
- Remember novelType is optional and defaults to total.
When it happens
Trigger: Malformed type: wrong segment order, missing category, unknown period (e.g. 'annual'), unknown category (e.g. '3'), unknown novelType (e.g. 're' — note 're' is a valid NarouSearchParams type but NOT a NovelType ranking value), or extra underscore segments.
Common situations: Hand-building the URL without consulting the route's parameters.type.options table; confusing the isekai format (period_category_novelType) with the genre format (period_genre_novelType); copy-pasting a genre-ranking URL into the isekai route.
Related errors
- Invalid ranking type: ${type}
- Invalid general ranking type: ${type}
- Invalid genre ranking type: ${type}
- Invalid ranking type: ${type}
- Invalid subsite: ${sub}
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/ba95056efe7c49db.
Report an issue: GitHub.