{"record":{"id":"e630fa3378c585f3","repo":"DIYgod/RSSHub","slug":"unknown-type-item-type-e630fa","errorCode":null,"errorMessage":"Unknown type: ${item.type}","messagePattern":"Unknown type: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/routes/zhihu/xhu/collection.ts","lineNumber":88,"sourceCode":"                    description = item.excerpt;\n\n                    break;\n\n                case 'answer':\n                    title = item.question.title;\n                    description = item.excerpt;\n\n                    break;\n\n                case 'pin': {\n                    const pinItem = generateData([item])[0];\n                    title = pinItem.title;\n                    description = pinItem.description;\n\n                    break;\n                }\n                default:\n                    throw new Error(`Unknown type: ${item.type}`);\n            }\n\n            return {\n                title: `收藏了内容：${title}`,\n                description,\n                author,\n                pubDate,\n                guid: link,\n                link,\n            };\n        }),\n    };\n}\n","sourceCodeStart":70,"sourceCodeEnd":102,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/zhihu/xhu/collection.ts#L70-L102","documentation":"Thrown from the item-type switch in the Zhihu xhu collection route. The switch maps `item.type` values (`article`, `answer`, `zvideo`, `pin`, etc.) to feed entries; any type not covered hits `default` and throws with the unknown type, so a single unsupported collected item aborts the whole collection feed.","triggerScenarios":"A user's Zhihu collection contains an item of a type the route does not handle — e.g. a collected `question`, `topic`, `column`, or a new content kind the mirror starts exposing. The `default` arm then throws.","commonSituations":"Zhihu/xhu mirror adds a new collectible content type; the collection mixes types (articles + a question) and the unhandled one trips the switch; the mirror renames a type string. The unhandled item poisons the entire feed.","solutions":["Add a `case` for the reported `item.type` that maps it to a feed entry (title/link/description), reusing the existing per-type helpers (e.g. `generateData`).","Make `default` skip the item (`continue`/filter it out) instead of throwing so unsupported entries don't break the rest of the collection.","Filter the items array by known types before the switch as a defensive pre-pass."],"exampleFix":"// before\ndefault:\n    throw new Error(`Unknown type: ${item.type}`);\n// after — skip unsupported collected items\ndefault:\n    return null;","handlingStrategy":"type-guard","validationCode":"const HANDLED_COLLECTION_TYPES = new Set(['article', 'answer', 'zvideo', 'pin']);\nfunction filterCollectionItems(items) {\n    return items.filter((item) => HANDLED_COLLECTION_TYPES.has(item.type));\n}","typeGuard":"type HandledCollectionType = 'article' | 'answer' | 'zvideo' | 'pin';\nfunction isHandledCollectionType(item: { type: string }): item is { type: HandledCollectionType } {\n    return new Set<HandledCollectionType>(['article','answer','zvideo','pin']).has(item.type as HandledCollectionType);\n}","tryCatchPattern":"// Filter unknown types out before building the feed\nconst items = rawItems.filter(isHandledCollectionType).map(/* existing mapping */);","preventionTips":["Pre-filter the collection items array to known types so one unsupported kind can't poison the feed.","Log skipped types to detect new collectible content kinds.","Add new types as explicit cases once the payload shape is confirmed."],"tags":["zhihu","xhu","collection","content-parsing","switch-enum"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}