DIYgod/RSSHub · warning · Error

Unknown action key: ${item.key}

Error message

Unknown action key: ${item.key}

What it means

Thrown as a plain Error from the default case of a switch statement that handles sspai (少数派) user activity items. The switch maps known item.key values (follow_user, like_article, comment_article, release_article, chosen_comment) to feed entry shapes. If the sspai activity API returns an item with an unrecognized key value, the default branch throws with the unknown key interpolated in the message. This is a forward-compatibility guard: it surfaces new API action types that the route has not been updated to handle.

Source

Thrown at lib/routes/sspai/activity.ts:99

                    item_url = `https://sspai.com/post/${content_data.id}`;
                    break;
                case 'comment_article':
                    item_title = `${item.author.nickname}${item.action}:${content_data.article_title}`;
                    item_desc = content_data.comment;
                    item_url = `https://sspai.com/post/${content_data.article_id}`;
                    break;
                case 'release_article':
                    item_title = `${item.author.nickname}${item.action}:${content_data.title}`;
                    item_desc = content_data.summary;
                    item_url = `https://sspai.com/post/${content_data.id}`;
                    break;
                case 'chosen_comment':
                    item_title = `${item.author.nickname}在文章「${content_data.article_title}」下的${item.action}`;
                    item_desc = content_data.comment;
                    item_url = content_data.comment;
                    break;
                default:
                    throw new Error(`Unknown action key: ${item.key}`);
            }

            return {
                title: item_title,
                description: item_desc,
                link: item_url,
                pubDate: parseDate(item.created_at * 1000),
            };
        }),
    };
}

View on GitHub (pinned to bed535e087)

Solutions

  1. Inspect the sspai API response to identify the new item.key value: fetch the activity endpoint with the user's slug and examine the data array.
  2. Add a new case branch in the switch statement for the unknown key, mapping it to appropriate title/description/link fields.
  3. As a quick workaround to prevent total feed failure, change the default case from `throw` to `return null` (or skip) so other items still render — but this masks the problem and should be fixed properly.
  4. File an issue or PR to add support for the new activity type.

Example fix

// before
default:
    throw new Error(`Unknown action key: ${item.key}`);

// after (graceful skip)
default:
    return null;

// after (proper handling of new type)
case 'like_comment':
    item_title = `${item.author.nickname}${item.action}:${content_data.comment}`;
    item_desc = content_data.comment;
    item_url = `https://sspai.com/post/${content_data.article_id}`;
    break;
Defensive patterns

Strategy: fallback

Validate before calling

const KNOWN_KEYS = new Set(['follow_user', 'like_article', 'comment_article', 'release_article', 'chosen_comment']);
// Before mapping, filter out unknown keys or handle gracefully
data.filter((item) => KNOWN_KEYS.has(item.key)).map(/* ... */)

Type guard

const KNOWN_ACTION_KEYS = ['follow_user', 'like_article', 'comment_article', 'release_article', 'chosen_comment'] as const;
type ActionKey = typeof KNOWN_ACTION_KEYS[number];
function isKnownActionKey(key: string): key is ActionKey {
    return (KNOWN_ACTION_KEYS as readonly string[]).includes(key);
}

Try / catch

item: data
    .filter((item) => isKnownActionKey(item.key))
    .map((item) => {
        // switch on item.key — TS now narrows to ActionKey
        switch (item.key) {
            // ...
        }
    }),

Prevention

When it happens

Trigger: The sspai API (/api/v1/information/user/activity/page/get) returns an activity item whose `key` field is a value not in the switch (e.g. 'like_comment', 'follow_collection', or any newly introduced activity type). This causes the entire feed generation to fail with this error, losing all items in the batch.

Common situations: sspai adds a new activity type to their platform (e.g. a new 'bookmark' or 'share' action) and the API starts returning it; the activity list for a specific user happens to contain only items of the new type; or sspai renames an existing action key.

Related errors


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