DIYgod/RSSHub · error

Unknown type: ${item.type}

Error message

Unknown type: ${item.type}

What it means

Thrown by the `default` arm of the item-type switch in the Zhihu xhu zhuanlan route. The switch handles known `item.type` values including `zvideo`; any item whose type is not modeled triggers this throw, echoing the type. Like the sibling routes, one unhandled item fails the whole feed.

Source

Thrown at lib/routes/zhihu/xhu/zhuanlan.ts:105

                    author = item.question.author ? item.question.author.name : '';
                    link = `https://www.zhihu.com/question/${item.question.id}/answer/${item.id}`;
                    pubDate = parseDate(item.created_time * 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,
                description,
                author,
                pubDate,
                guid: link,
                link,
            };
        }),
    };
}

View on GitHub (pinned to bed535e087)

Solutions

  1. Add a `case` for the reported `item.type` that produces a feed entry (reuse the title/link/description mapping pattern).
  2. Make `default` skip the unknown item (filter it out) instead of throwing so the rest of the column still renders.
  3. Keep this type list in sync with the official `zhuanlan.ts` route (error 673).

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', /* ...existing types... */ 'zvideo']);
function filterZhuanlanItems(items) {
    return items.filter((item) => HANDLED_ZHUANLAN_TYPES.has(item.type));
}

Type guard

type HandledZhuanlanType = 'article' | 'zvideo'; // extend with actual known set
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

When it happens

Trigger: The xhu zhuanlan/column endpoint returns an item whose `type` is outside the handled set — e.g. a new content type the mirror passes through, or a mixed feed where the column surfaces a type the route never encoded.

Common situations: Zhihu or the xhu mirror introduces a new content type surfaced inside a column feed; a type string is renamed; the column aggregates `article` + an unhandled kind. The throw aborts the entire column feed.

Related errors


AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12). Data as JSON: /api/errors/3b17424dc74c28a4. Report an issue: GitHub.