DIYgod/RSSHub · error
Unknown type: ${item.type}
Error message
Unknown type: ${item.type} What it means
The official-endpoint counterpart of error 672: the `default` arm of the item-type switch in `zhihu/zhuanlan.ts`. It handles the known `item.type` values (including `zvideo`) and throws for anything else, reporting the type. A single unhandled item aborts the whole zhuanlan feed.
Source
Thrown at lib/routes/zhihu/zhuanlan.ts:118
link = item.url;
author = item.author.name;
pubDate = parseDate(item.created * 1000);
break;
case 'zvideo':
// 如果类型是zvideo,id即为视频地址参数
title = item.title;
link = `https://www.zhihu.com/zvideo/${item.id}`;
author = item.author.name;
pubDate = parseDate(item.created_at * 1000);
// 判断是否存在视频简介
description = item.description ? `${item.description} <br> <br> <a href="${link}">视频内容请跳转至原页面观看</a>` : `<a href="${link}">视频内容请跳转至原页面观看</a>`;
break;
default:
throw new Error(`Unknown type: ${item.type}`);
}
return {
title,
link,
description,
pubDate,
author,
};
});
return {
description,
item,
title: `知乎专栏-${title}`,
link: url,
};
}
View on GitHub (pinned to bed535e087)
Solutions
- Add a `case` for the reported `item.type` mapping it to the standard feed fields (title/link/description/author/pubDate).
- Make `default` skip the unknown item instead of throwing so the rest of the column renders.
- Mirror any new case into the xhu `zhuanlan.ts` route (error 672) to keep both in sync.
Example fix
// before
default:
throw new Error(`Unknown type: ${item.type}`);
// after — skip unknown items
default:
return null; Defensive patterns
Strategy: type-guard
Validate before calling
const HANDLED_ZHUANLAN_TYPES = new Set(['article', 'zvideo']); // extend with full known set
function filterZhuanlanItems(items) {
return items.filter((item) => HANDLED_ZHUANLAN_TYPES.has(item.type));
} Type guard
type HandledZhuanlanType = 'article' | 'zvideo';
function isHandledZhuanlanType(item: { type: string }): item is { type: HandledZhuanlanType } {
return new Set<HandledZhuanlanType>(['article','zvideo']).has(item.type as HandledZhuanlanType);
} Try / catch
const items = rawItems.filter(isHandledZhuanlanType).map(/* existing mapping */);
Prevention
- Filter items to known types before the switch so an unknown entry is skipped instead of aborting the feed.
- Sync new cases into the xhu zhuanlan.ts route.
- Log unknown types to catch Zhihu API additions promptly.
When it happens
Trigger: The official Zhihu column/zhuanlan API returns an item whose `type` is not in the handled set — Zhihu added a new content kind surfaced in a column, or renamed a type string.
Common situations: Zhihu ships a new content type inside zhuanlan feeds; a column mixes `article` with an unhandled kind; a type-string rename. The throw fails the entire feed rather than just the unsupported entry.
Related errors
- Unknown type: ${contentItem.type}
- Unknown type: ${contentItem.type}
- Unknown type: ${item.type}
- Unknown type: ${item.type}
- Unhandled thirdparty on ${link}: ${elem.attr('alias')}
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/8bcbb3f32078a919.
Report an issue: GitHub.