DIYgod/RSSHub · error · Error
Unknown node type: ${node.type}
Error message
Unknown node type: ${node.type} What it means
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.
Source
Thrown at lib/routes/digg/community.tsx:124
case 'paragraph':
if (children.length === 0) {
return null;
}
return (
<p>
{children.map((element, index) => (
<DiggDescription node={element} key={index} />
))}
<br />
</p>
);
case 'text':
return node.text || '';
default:
throw new Error(`Unknown node type: ${node.type}`);
}
};
async function handler(ctx) {
const { community } = ctx.req.param();
const limit = Number(ctx.req.query('limit') ?? 30);
const communityData = await cache.tryGet(`digg:community:${community}`, async () => {
const {
data: { community: communityData },
} = await ofetch(graphqlUrl, {
method: 'POST',
body: {
query: /* GraphQL */ `
query CommunityQuery($id: ID, $slug: String) {
community(where: { _id_EQ: $id, slug_EQ: $slug }) {
...CommunityFragment
topContributors {View on GitHub (pinned to bed535e087)
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.
Example fix
// before
// default:
// throw new Error(`Unknown node type: ${node.type}`);
// after
// default:
// return ''; Defensive patterns
Strategy: fallback
Validate before calling
const HANDLED_NODE_TYPES = new Set(['paragraph', 'text']);
function isHandledNode(node: { type: string }): boolean {
return HANDLED_NODE_TYPES.has(node.type);
} Type guard
function isHandledNode(node: { type: string }): node is { type: 'paragraph' | 'text' } {
return node.type === 'paragraph' || node.type === 'text';
} Try / catch
try {
return <DiggDescription node={element} />;
} catch (e) {
// unknown node type — render nothing rather than fail the feed
return null;
} Prevention
- 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.
When it happens
Trigger: Digg's API starts returning a node type the switch doesn't cover (e.g. link, image, list, heading, mention).
Common situations: Digg ships a new rich-text block type after this handler was written; older posts render fine but newer ones fail.
Related errors
- Unknown type: ${v.type}
- Unhandle type: ${c.type}
- Unhandled attachment type: ${attachment.contentType} for pos
- Unhandled media type: ${media.mimetype}
- Unknown action key: ${item.key}
AI-assisted analysis of DIYgod/RSSHub@bed535e087 (2026-08-12).
Data as JSON: /api/errors/488cba92d707b1b3.
Report an issue: GitHub.