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

  1. Inspect the failing API response to identify the new type value.
  2. Add a case in the switch mapping the new type to its detail URL, or skip unknown types with `continue` instead of throwing.
  3. 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

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


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