DIYgod/RSSHub · error
Unknown type: ${item.type}
Error message
Unknown type: ${item.type} What it means
Thrown by the aiyanxishe home route when an item returned by the upstream yanxishe API has a `type` field that is neither 'article' nor 'paper'. The switch maps those two types to detail URLs; any new type the API starts returning falls through to the default and aborts the whole feed.
Source
Thrown at lib/routes-deprecated/aiyanxishe/home.js:101
switch (item.type) {
case 'blog':
itemUrl += '&type=null';
break;
case 'article':
itemUrl = `https://api.yanxishe.com/api/stranslate/article/${item.id}?token=null&type=null`;
break;
case 'paper':
itemUrl = `https://api.yanxishe.com/api/spaper/detail?token=null&id=${item.id}`;
break;
default:
throw new Error(`Unknown type: ${item.type}`);
}
const cache = await ctx.cache.get(itemUrl);
if (cache) {
return JSON.parse(cache);
}
const response = await got({
method: 'get',
url: itemUrl,
});
const result = ProcessFeed(item.type, response.data.data, item.id);
const single = {
title: item.zh_title,
description: result.description,
pubDate: new Date(Number.parseFloat(item.published_time + '000')).toUTCString(),View on GitHub (pinned to bed535e087)
Solutions
- Inspect the failing API response to identify the new type value.
- Add a case in the switch mapping the new type to its detail URL, or skip unknown types with `continue` instead of throwing.
- Report the upstream change to RSSHub maintainers with a sample payload.
Example fix
// before
default:
throw new Error(`Unknown type: ${item.type}`);
// after — skip items we cannot handle instead of failing the feed
default:
continue; Defensive patterns
Strategy: fallback
Validate before calling
const KNOWN_TYPES = new Set(['article', 'paper']); const items = (await got(url)).data; const handled = items.filter((i) => KNOWN_TYPES.has(i.type));
Type guard
const isSupportedType = (t: unknown): t is 'article' | 'paper' => t === 'article' || t === 'paper';
Try / catch
// Route-level: degrade instead of failing the whole feed. const detail = isSupportedType(item.type) ? await fetchDetail(item) : null;
Prevention
- Default to skipping unknown types rather than throwing.
- Log unknown types so upstream drift is visible.
- Pin a schema test against a recorded API response.
When it happens
Trigger: The yanxishe API introduces a new content type (e.g. 'video', 'column', 'report') and returns it in the list response.
Common situations: Upstream API schema drift; a previously-unused type now appearing in responses; A/B test variant returning tagged items.
Related errors
- this route is empty, please check the original site or <a hr
- Comic Not Found - ${name}
- Failed to extract Algolia credentials from iapp.org
- 软件信息不存在,请报告这个问题
- 新闻信息不存在,请报告这个问题
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/84f240658fa7d95b.
Report an issue: GitHub.