DIYgod/RSSHub · warning · Error
Unknown host: ${url.host}
Error message
Unknown host: ${url.host} What it means
Thrown by the Maonan district government route inside a cache.tryGet callback when processing individual article links. After extracting article URLs from the list page, each link's URL host is checked in a switch statement. Only 'mp.weixin.qq.com' and 'www.maonan.gov.cn' have handlers. Any other host triggers this error.
Source
Thrown at lib/routes/gov/maonan/maonan.ts:154
case '/zcjdpt':
return {
title: content('meta[name="ArticleTitle"]').attr('content')!,
description: content('.wrap').html(),
pubDate,
link,
author: content('meta[name="ContentSource"]').attr('content') === '本网' ? '茂名市茂南区人民政府网' : content('meta[name="ContentSource"]').attr('content'),
};
default:
return {
title: content('.newsContainer_title').text(),
description: content('.newsContainer_text').html(),
pubDate,
link,
author: content('.author').text().trim() === '本网' ? '茂名市茂南区人民政府网' : content('.author').text().trim(),
};
}
default:
throw new Error(`Unknown host: ${url.host}`);
}
});
})
);
return {
title: `茂名市茂南区人民政府 - ${name}`,
link: `${host}/${id}`,
item: items,
};
}
View on GitHub (pinned to bed535e087)
Solutions
- Inspect the article list page to identify what new hosts are appearing in links
- Add a new case to the switch statement in the cache.tryGet callback for the new host
- If the links are non-article navigation, tighten the list CSS selector to exclude them
- Consider making the error non-fatal by returning a partial item instead of throwing, to avoid breaking the entire feed
Example fix
// before
default:
throw new Error(`Unknown host: ${url.host}`);
// after (graceful degradation — skip unknown hosts instead of failing the entire feed)
default:
return {
title: $item.text(),
description: `Content from ${url.host} is not supported`,
pubDate,
link,
author: url.host,
}; Defensive patterns
Strategy: try-catch
Type guard
const SUPPORTED_HOSTS = new Set(['mp.weixin.qq.com', 'www.maonan.gov.cn']);
function isSupportedHost(url: URL): boolean {
return SUPPORTED_HOSTS.has(url.host);
} Try / catch
// Inside the Promise.all map, catch per-item errors instead of failing the feed:
const items = await Promise.all(
list.map(async (i, item) => {
try {
// ... existing logic
} catch (e) {
if (e.message.includes('Unknown host')) {
return null; // skip unsupported hosts gracefully
}
throw e;
}
})
);
const validItems = items.filter(Boolean); Prevention
- Filter the list selector to only include links to known hosts before processing
- Use a Set of supported hosts for O(1) lookup
- Return partial results (skip unsupported links) instead of failing the entire feed
- Monitor for new hosts appearing in the article list
When it happens
Trigger: The article list page (www.maonan.gov.cn/{id}/) contains links whose host is neither mp.weixin.qq.com (WeChat articles) nor www.maonan.gov.cn (government site articles). This could be an external redirect, a CDN link, or a new subdomain. The error is thrown inside a Promise.all map, so it will reject the entire feed generation.
Common situations: The Maonan government site added links to a new domain or subdomain (e.g., a new content management system); external partner links appear in the article list; the list CSS selector matches unintended links (e.g., navigation links to other gov.cn subdomains).
Related errors
- Data source ID not found
- No content found. The page structure might have changed.
- Bad category. See <a href="https://docs.rsshub.app/routes/go
- Bad category. See <a href="https://docs.rsshub.app/routes/go
- Nanjing, Cannot find page
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/e900aebd94a1a96d.
Report an issue: GitHub.