DIYgod/RSSHub · warning · Error
Unknown type: ${x}
Error message
Unknown type: ${x} What it means
When building a FurAffinity user's contact-info description block, the route iterates over the keys of each contact element and handles only three known keys: title, name, and link. Any other key in the element hits the default branch and throws. This is a defensive parser designed to surface unexpected HTML/schema changes rather than silently dropping data.
Source
Thrown at lib/routes/furaffinity/user.ts:91
const contact_information = data.contact_information;
let contact_result = 'none <br> <br> ';
// 对一个或多个用户联系方式进行遍历
if (contact_information) {
contact_result = '';
for (const element of contact_information) {
for (const x in element) {
switch (x) {
case 'title':
contact_result += `Title: ${element[x]} <br> `;
break;
case 'name':
contact_result += `Name: ${element[x]} <br> `;
break;
case 'link':
contact_result += `Link: ${element[x]} <br> `;
break;
default:
throw new Error(`Unknown type: ${x}`);
}
}
contact_result += '<br> ';
}
}
const description = `Name: ${name} <br> Profile: ${profile} <br> Account Type: ${account_type} <br>
Avatar: ${avatar} <br> Full Name: ${full_name} <br> Artist Type: ${artist_type} <br> User Title: ${user_title} <br>
Registered Since: ${registered_since} <br> Current Mood: ${current_mood} <br> <br> Artist Profile: <br> ${artist_profile} <br> <br>
Pageviews: ${pageviews} <br> Submissions: ${submissions} <br> Comments_Received: ${comments_received} <br> Comments Given: ${comments_given} <br>
Journals: ${journals} <br> Favorite: ${favorite} <br> <br> Artist Information: <br> Species: ${species} <br> Personal Quote: ${personal_quote} <br> Music Type/Genre: ${music_type_genre} <br>
Favorite Movie: ${favorites_movie} <br> Favorite Game: ${favorites_game} <br> Favorite Game Platform: ${favorites_game_platform} <br> Favorite Artist: ${favorites_artist} <br>
Favorite Animal: ${favorites_animal} <br> Favorite Website: ${favorites_website} <br> Favorite Food: ${favorites_food} <br> <br> Contact Information: <br> ${contact_result}
Watchers Count: ${watchers_count} <br> Watching Count: ${watching_count} `;
const items: Array<{ title: string; link: string; description: string }> = [
{
title: `${data.name}'s User Profile`,View on GitHub (pinned to bed535e087)
Solutions
- Read the unknown key name (x) from the error message to learn which new field FurAffinity added.
- Add a case for the new key in the switch (or a safe default that appends it generically) and redeploy.
- Tighten the upstream selector so only expected contact elements are iterated.
- Consider replacing the throw with a logger.warn so a single unknown key does not break the whole feed.
Example fix
// before
default:
throw new Error(`Unknown type: ${x}`);
// after
default:
logger.warn(`Unknown contact field type: ${x}`);
contact_result += `${x}: ${element[x]} <br> `;
break; Defensive patterns
Strategy: fallback
Validate before calling
const knownKeys = new Set(['title', 'name', 'link']); // log unknown keys instead of throwing
Type guard
const isKnownContactKey = (k: string): k is 'title' | 'name' | 'link' => knownKeys.has(k);
Prevention
- Replace the throw with a logger.warn so one new field does not break the feed. Generically append unknown fields rather than failing. Add a regression test using a sample profile HTML fixture.
When it happens
Trigger: FurAffinity adds a new contact field type (e.g. an icon, type, or label key) to its user-profile HTML, or the scraper's parsing logic mis-assigns an attribute as a key. The error message includes the unknown key name (x), making it easy to identify which new field triggered the failure.
Common situations: FurAffinity rolling out profile template changes that add new contact metadata; the scraping selector capturing broader elements than intended; locale-specific profile variants adding extra fields.
Related errors
- 无法解析页面数据,请检查漫画 ID 是否正确或页面结构是否变动
- 无法解析页面 Props 数据
- 无法解析页面 HTML 数据,可能触发了反爬策略或页面结构巨变
- 无法在 HTML 缓存中提取核心数据对象
- 成功获取数据对象,但未找到作品基本信息
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/fb76cea2efa77bd0.
Report an issue: GitHub.