{"record":{"id":"488cba92d707b1b3","repo":"DIYgod/RSSHub","slug":"unknown-node-type-node-type","errorCode":null,"errorMessage":"Unknown node type: ${node.type}","messagePattern":"Unknown node type: (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"lib/routes/digg/community.tsx","lineNumber":124,"sourceCode":"\n        case 'paragraph':\n            if (children.length === 0) {\n                return null;\n            }\n            return (\n                <p>\n                    {children.map((element, index) => (\n                        <DiggDescription node={element} key={index} />\n                    ))}\n                    <br />\n                </p>\n            );\n\n        case 'text':\n            return node.text || '';\n\n        default:\n            throw new Error(`Unknown node type: ${node.type}`);\n    }\n};\n\nasync function handler(ctx) {\n    const { community } = ctx.req.param();\n    const limit = Number(ctx.req.query('limit') ?? 30);\n\n    const communityData = await cache.tryGet(`digg:community:${community}`, async () => {\n        const {\n            data: { community: communityData },\n        } = await ofetch(graphqlUrl, {\n            method: 'POST',\n            body: {\n                query: /* GraphQL */ `\n                    query CommunityQuery($id: ID, $slug: String) {\n                        community(where: { _id_EQ: $id, slug_EQ: $slug }) {\n                            ...CommunityFragment\n                            topContributors {","sourceCodeStart":106,"sourceCodeEnd":142,"githubUrl":"https://github.com/DIYgod/RSSHub/blob/bed535e0879dc71c5aff6f1e7bd1ac21ede40115/lib/routes/digg/community.tsx#L106-L142","documentation":"DiggDescription renders rich-text nodes returned by Digg's GraphQL API. The switch handles only `paragraph` and `text` node types; every other `node.type` falls through to `default` and throws a generic Error. This is a parser-completeness gap driven by upstream schema growth, not by user input.","triggerScenarios":"Digg's API starts returning a node type the switch doesn't cover (e.g. link, image, list, heading, mention).","commonSituations":"Digg ships a new rich-text block type after this handler was written; older posts render fine but newer ones fail.","solutions":["Inspect the failing API response to identify the new `node.type`, then add a rendering case for it.","As a stopgap, return an empty string in the `default` arm so unknown nodes degrade gracefully instead of failing the feed.","Pin or normalise the API version if Digg exposes one."],"exampleFix":"// before\n//   default:\n//       throw new Error(`Unknown node type: ${node.type}`);\n// after\n//   default:\n//       return '';","handlingStrategy":"fallback","validationCode":"const HANDLED_NODE_TYPES = new Set(['paragraph', 'text']);\nfunction isHandledNode(node: { type: string }): boolean {\n  return HANDLED_NODE_TYPES.has(node.type);\n}","typeGuard":"function isHandledNode(node: { type: string }): node is { type: 'paragraph' | 'text' } {\n  return node.type === 'paragraph' || node.type === 'text';\n}","tryCatchPattern":"try {\n  return <DiggDescription node={element} />;\n} catch (e) {\n  // unknown node type — render nothing rather than fail the feed\n  return null;\n}","preventionTips":["Never throw from a renderer's default arm; return '' so one unknown node cannot kill the feed.","Log unknown node types to a metric so schema drift is visible.","Add unit tests covering every node type returned by a sample API response."],"tags":["api","parsing","switch-default","schema-drift"],"backgroundTag":null,"analyzedSha":"bed535e0879dc71c5aff6f1e7bd1ac21ede40115","analyzedAt":"2026-08-12T19:29:35.364Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}