{"record":{"id":"44027f4dc5d7d448","repo":"DIYgod/RSSHub","slug":"unknown-type-contentitem-type-44027f","errorCode":null,"errorMessage":"Unknown type: ${contentItem.type}","messagePattern":"Unknown type: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"lib/routes/zhihu/xhu/activities.ts","lineNumber":115,"sourceCode":"\n                                break;\n\n                            case 'link':\n                                link = `<p><a href=\"${contentItem.url}\" target=\"_blank\">${contentItem.title}</a></p>`;\n\n                                break;\n\n                            case 'video':\n                                link = `<p><video\n                                controls=\"controls\"\n                                width=\"${contentItem.playlist[1].width}\"\n                                height=\"${contentItem.playlist[1].height}\"\n                                src=\"${contentItem.playlist[1].url}\"></video></p>`;\n\n                                break;\n\n                            default:\n                                throw new Error(`Unknown type: ${contentItem.type}`);\n                        }\n                    }\n                    description = `${text}${link}${images.join('')}`;\n                    url = `https://www.zhihu.com/pin/${detail.id}`;\n                    break;\n                case 'question':\n                    title = detail.title;\n                    author = detail.author.name;\n                    description = processImage(detail.detail);\n                    url = `https://www.zhihu.com/question/${detail.id}`;\n                    break;\n                case 'collection':\n                    title = detail.title;\n                    url = `https://www.zhihu.com/collection/${detail.id}`;\n                    break;\n                case 'column':\n                    title = detail.title;\n                    description = `<p>${detail.intro}</p><p><img src=\"${detail.image_url}\"/></p>`;","sourceCodeStart":97,"sourceCodeEnd":133,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/zhihu/xhu/activities.ts#L97-L133","documentation":"The mirror of error 664 but in the `xhu` (third-party Zhihu mirror API) activities route. The inner switch over a pin's content items handles `text`, `image`, `link`, `video` and `link_card`; any other `contentItem.type` reaches the `default` and throws, reporting the unknown type.","triggerScenarios":"The xhu mirror API returns a pin content block whose `type` is not in the handled set — because the mirror exposes a newer Zhihu content type, or the mirror normalizes types differently than the official endpoint.","commonSituations":"The xhu mirror is updated to pass through a new Zhihu pin block type; a reposted/nested pin carries a type the switch doesn't model; type-string casing or naming differs from the official route. The throw fails the whole activity feed.","solutions":["Use the reported `contentItem.type` to add a matching `case` (link/image/iframe as appropriate to the payload fields).","Make the `default` arm skip unknown items (`break` with no HTML) so one unsupported block cannot break the feed.","Cross-reference the official `activities.ts` route to keep the two type lists in sync."],"exampleFix":"// before\ndefault:\n    throw new Error(`Unknown type: ${contentItem.type}`);\n// after — degrade gracefully\ndefault:\n    break;","handlingStrategy":"type-guard","validationCode":"const HANDLED = new Set(['text', 'image', 'link', 'video', 'link_card']);\nfunction safePinContent(content) {\n    return Array.isArray(content) ? content.filter((c) => HANDLED.has(c.type)) : [];\n}","typeGuard":"type HandledPinType = 'text' | 'image' | 'link' | 'video' | 'link_card';\nfunction isHandledPinType(item: { type: string }): item is { type: HandledPinType } {\n    return new Set<HandledPinType>(['text','image','link','video','link_card']).has(item.type as HandledPinType);\n}","tryCatchPattern":"for (const contentItem of detail.content) {\n    if (!isHandledPinType(contentItem)) continue;\n    // existing switch\n}","preventionTips":["Filter pin content to known types before switching so unknown blocks are skipped.","Keep this type set in sync with the official activities.ts route.","Log new types at warn level to catch mirror/API additions."],"tags":["zhihu","xhu","content-parsing","switch-enum","api-change"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}