DIYgod/RSSHub · error · Error

Unknown asset type: ${content.assetType} in ${item.link}

Error message

Unknown asset type: ${content.assetType} in ${item.link}

What it means

The AFR (Financial Review) renderer switches on content.assetType and handles liveArticle, article, and featureArticle. Any other assetType hits the default branch and throws a generic `Error` reporting the offending type and the item link, so unexpected content surfaces loudly rather than silently rendering an empty description.

Source

Thrown at lib/routes/afr/utils.ts:25

    const $ = load(response);

    const reduxState = JSON.parse($('script#__REDUX_STATE__').text().replaceAll(':undefined', ':null').match('__REDUX_STATE__=(.*);')?.[1] || '{}');

    const content = reduxState.page.content;
    const asset = content.asset;

    switch (content.assetType) {
        case 'liveArticle':
            item.description = asset.posts.map((post) => `<h2>${post.asset.headlines.headline}</h2>${post.asset.body}`).join('');
            break;

        case 'article':
        case 'featureArticle':
            item.description = renderArticle(asset, item.link);
            break;

        default:
            throw new Error(`Unknown asset type: ${content.assetType} in ${item.link}`);
    }

    return item;
};

const renderArticle = (asset, link: string) => {
    const $ = load(asset.body, null, false);
    $('x-placeholder').each((_, el) => {
        const $el = $(el);
        const id = $el.attr('id');
        if (!id) {
            $el.replaceWith('');
        }

        const placeholder = asset.bodyPlaceholders[id!];
        switch (placeholder?.type) {
            case 'callout':
            case 'relatedStory':

View on GitHub (pinned to bed535e087)

Solutions

  1. Report the assetType value and item link to the route maintainers so a new case can be added.
  2. Short-term, filter the offending item out of the list before calling the renderer.
  3. Pin to a feed/query that returns only known asset types.

Example fix

// before
switch (content.assetType) {
    case 'liveArticle': ...
    case 'article':
    case 'featureArticle': ...
    default: throw new Error(`Unknown asset type: ${content.assetType} in ${item.link}`);
}
// after — degrade gracefully instead of failing the whole feed
    default:
        item.description = asset?.body ?? '';
        item.title = item.title ?? 'Unsupported asset type ' + content.assetType;
Defensive patterns

Strategy: type-guard

Validate before calling

const KNOWN_ASSET_TYPES = new Set(['liveArticle','article','featureArticle']);
function knownAfrAsset(t) {
  return KNOWN_ASSET_TYPES.has(t);
}

Type guard

function isKnownAfrAssetType(t): t is 'liveArticle'|'article'|'featureArticle' {
  return t === 'liveArticle' || t === 'article' || t === 'featureArticle';
}

Try / catch

try {
  return renderAfrItem(content, item);
} catch (e) {
  if (e instanceof Error && /Unknown asset type/.test(e.message)) {
    // degrade: keep the item with whatever body is available, instead of failing the feed
    item.description = content?.asset?.body ?? '';
    return item;
  }
  throw e;
}

Prevention

When it happens

Trigger: AFR's live-article API returns an item whose content.assetType is something new (e.g. 'video', 'gallery', 'podcast', 'newsletter') not covered by the switch.

Common situations: Upstream schema/pilot change introducing a new content type; a feed entry that points at a previously-unseen article format.

Related errors


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