DIYgod/RSSHub · warning
Bad type
Error message
Bad type
What it means
Thrown by the emi-nitta home route when ctx.params.type does not match a key in the route's config map (the `cfg` object that maps a type to a link). Only the configured types (news, live, etc. per the map) are valid.
Source
Thrown at lib/routes-deprecated/emi-nitta/home.js:30
},
news: {
link: '/contents/news',
title: 'Emi Nitta - News',
description: 'News of Emi Nitta',
},
};
const get_date = (o) => {
const match = /(\d{4}\.\d+\.\d+)/.exec(o.text().trim());
const date = match ? match[1] : o.attr('datetime');
return new Date(date + ' GMT+9').toUTCString();
};
module.exports = async (ctx) => {
const cfg = config[ctx.params.type];
if (!cfg) {
throw new Error('Bad type');
}
const response = await got({
method: 'get',
url: url.resolve(root_url, cfg.link),
});
const $ = cheerio.load(response.data);
const list = $('article.details ul.list-unstyled li a')
.slice(0, 10)
.map((_, item) => {
item = $(item);
return {
title: item.find('div.title h3').text(),
link: item.attr('href'),
pubDate: get_date(item.find('time')),
};
})View on GitHub (pinned to bed535e087)
Solutions
- Use one of the types defined in the route's config map (check the route source for the keys).
- Omit the segment if the route defines a sensible default (it does not here — supply a valid type).
- If a legitimate type is missing, add it to the config map with its link.
Example fix
// before /emi-nitta/foobar // after /emi-nitta/news
Defensive patterns
Strategy: type-guard
Validate before calling
const cfg = CONFIG_MAP[ctx.params.type];
if (!cfg) throw new Error('Bad type'); Type guard
const isValidType = (t: string): t is keyof typeof CONFIG_MAP => t in CONFIG_MAP;
Prevention
- Derive the valid type list from the config map itself so docs cannot drift.
- Reject unknown types at the route entry with a helpful message listing valid values.
When it happens
Trigger: Request to /emi-nitta/:type with a type that is not one of the keys defined in the route's exported config object.
Common situations: Typo in the type segment; user guesses a type that was never configured; route's config map was edited and a previously-valid type removed.
Related errors
- Invalid lang
- Invalid URL property: ${prop}
- Invalid Engine Value: ${engine}, please check your config.
- Invalid language code
- Invalid subdomain
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/c1f035c5f1ff1695.
Report an issue: GitHub.