{"record":{"id":"ac1c12cbdab0fed9","repo":"facebook/docusaurus","slug":"unknown-item-type-json-stringify-item","errorCode":null,"errorMessage":"unknown item type ${JSON.stringify(item)}","messagePattern":"unknown item type (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/docusaurus-theme-classic/src/theme/DocCard/index.tsx","lineNumber":85,"sourceCode":"  return (\n    <Layout\n      item={item}\n      className={item.className}\n      href={item.href}\n      description={item.description ?? doc?.description}\n      {...getIconTitleProps(item)}\n    />\n  );\n}\n\nexport default function DocCard({item}: Props): ReactNode {\n  switch (item.type) {\n    case 'link':\n      return <CardLink item={item} />;\n    case 'category':\n      return <CardCategory item={item} />;\n    default:\n      throw new Error(`unknown item type ${JSON.stringify(item)}`);\n  }\n}\n","sourceCodeStart":67,"sourceCodeEnd":88,"githubUrl":"https://github.com/facebook/docusaurus/blob/3f483e80e326cc646b54b83d564b3f0c4881b9a6/packages/docusaurus-theme-classic/src/theme/DocCard/index.tsx#L67-L88","documentation":"Thrown by `DocCard` when `item.type` is neither `'link'` nor `'category'`. `DocCard` renders sidebar items in a docs sidebar grid, and the sidebar item taxonomy is restricted to those two kinds. Hitting `default` means the docs sidebar data contains an item type the renderer does not know how to draw.","triggerScenarios":"A custom sidebar generator (the `async sidebarItems` callback in `docusaurus.config`) returns an object whose `type` is something other than `'link'` or `'category'`. Also possible if a swizzled `DocCard` was not updated after a new sidebar item type was introduced elsewhere.","commonSituations":"Authoring a custom `sidebarItemsGenerator` that emits items with `type: 'doc'` or `type: 'html'` (those are navbar/sidebar-item kinds, not DocCard kinds); mismatched swizzle after an upgrade; feeding hand-built sidebar JSON with a wrong `type` field.","solutions":["Check the `type` field of every item returned by your `sidebarItemsGenerator`; only `'link'` and `'category'` are renderable by `DocCard`.","If you need other types, render them with a custom/swizzled `DocCard` that handles them before the `default` branch.","Validate the sidebar tree shape against the `SidebarsDoc`/sidebar item types from `@docusaurus/plugin-content-docs`."],"exampleFix":"// before (custom generator returns wrong type)\nasync function myGenerator({isCategoryIndex}) {\n  return [{type: 'doc', id: 'intro', label: 'Intro'}]; // 'doc' is invalid for DocCard\n}\n// after\nasync function myGenerator() {\n  return [{type: 'link', href: '/docs/intro', label: 'Intro'}];\n}","handlingStrategy":"type-guard","validationCode":"function isDocCardItem(item: {type?: string}): boolean {\n  return item.type === 'link' || item.type === 'category';\n}\n// in a custom sidebarItemsGenerator, filter/validate before returning","typeGuard":"import type {SidebarsDoc} from '@docusaurus/plugin-content-docs';\ntype DocCardItem = Extract<SidebarsDoc, {type:'link'}> | Extract<SidebarsDoc,{type:'category'}>;\nfunction isDocCardItem(item: any): item is DocCardItem {\n  return item?.type === 'link' || item?.type === 'category';\n}","tryCatchPattern":null,"preventionTips":["Only emit `'link'` or `'category'` items from `sidebarItemsGenerator` for DocCard-rendered sidebars.","Add a unit test asserting every generated item has a renderable type.","Re-swizzle DocCard after upgrades."],"tags":["react","switch-exhaustiveness","docs-sidebar","theme-classic"],"backgroundTag":null,"analyzedSha":"3f483e80e326cc646b54b83d564b3f0c4881b9a6","analyzedAt":"2026-08-12T13:25:04.382Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}