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
- Report the assetType value and item link to the route maintainers so a new case can be added.
- Short-term, filter the offending item out of the list before calling the renderer.
- 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
- Treat a new assetType as an upstream schema change — log it and report to maintainers.
- Filter items to known assetTypes before rendering if feed completeness is optional.
- Don't catch and silently drop; surface the type so the route can be extended.
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
- Unknown placeholder type: ${placeholder?.type} in ${link}
- Category not found
- Tag not found
- 日报数据不存在或为空
- Empty content: ${articleUrl}
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/f6e3d00523d32872.
Report an issue: GitHub.