{"record":{"id":"5042de18a64459f4","repo":"facebook/docusaurus","slug":"invalid-sidebar-items-collection-code-json-strin","errorCode":null,"errorMessage":"Invalid sidebar items collection code=${JSON.stringify(sidebar)} in ${place}: it must either be an array of sidebar items or a shorthand notation (which doesn't contain a code=${'type'} property). See url=${'https://docusaurus.io/docs/sidebar/items'} for all valid syntaxes.","messagePattern":"Invalid sidebar items collection code=(.+?) in (.+?): it must either be an array of sidebar items or a shorthand notation \\(which doesn't contain a code=(.+?) property\\)\\. See url=(.+?) for all valid syntaxes\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/docusaurus-plugin-content-docs/src/sidebars/normalization.ts","lineNumber":71,"sourceCode":"  if (item.type === 'category') {\n    const normalizedCategory: NormalizedSidebarItemCategory = {\n      ...item,\n      items: normalizeSidebar(\n        item.items,\n        logger.interpolate`code=${'items'} of the category name=${item.label}`,\n      ),\n    };\n    return [normalizedCategory];\n  }\n  return [item];\n}\n\nfunction normalizeSidebar(\n  sidebar: SidebarConfig,\n  place: string,\n): NormalizedSidebar {\n  if (!Array.isArray(sidebar) && !isCategoriesShorthand(sidebar)) {\n    throw new Error(\n      logger.interpolate`Invalid sidebar items collection code=${JSON.stringify(\n        sidebar,\n      )} in ${place}: it must either be an array of sidebar items or a shorthand notation (which doesn't contain a code=${'type'} property). See url=${'https://docusaurus.io/docs/sidebar/items'} for all valid syntaxes.`,\n    );\n  }\n\n  const normalizedSidebar = Array.isArray(sidebar)\n    ? sidebar\n    : normalizeCategoriesShorthand(sidebar);\n\n  return normalizedSidebar.flatMap((subItem) => normalizeItem(subItem));\n}\n\nexport function normalizeSidebars(\n  sidebars: SidebarsConfig,\n): NormalizedSidebars {\n  return _.mapValues(sidebars, (sidebar, id) =>\n    normalizeSidebar(sidebar, logger.interpolate`sidebar name=${id}`),","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/facebook/docusaurus/blob/3f483e80e326cc646b54b83d564b3f0c4881b9a6/packages/docusaurus-plugin-content-docs/src/sidebars/normalization.ts#L53-L89","documentation":"Thrown by normalizeSidebar() while the docs plugin converts the user's sidebars.js into its normalized internal form. A sidebar (or a category's items field, or an items slice) must be either an array of sidebar items or a categories shorthand object (an object whose keys are labels and whose values are item arrays, and which does NOT carry a top-level type property). Anything else is rejected.","triggerScenarios":"Returning a single sidebar item object from a function instead of wrapping it in an array; putting an object with a type property where the shorthand notation is expected; nesting a category's items as an object with type instead of an array; exporting a sidebar whose root is a bare string or a number.","commonSituations":"Refactoring sidebars.js and forgetting to wrap an item in []; copying a single category object from the docs into a sidebar key; accidentally assigning a full SidebarItemConfig (with type:'category') to a top-level sidebar entry that the parser tries to read as shorthand; JSON sidebars where a category's items field was serialized as an object map.","solutions":["Wrap the offending value in an array: change `mySidebar: {type:'category',...}` to `mySidebar: [{type:'category',...}]`.","If you meant shorthand notation, remove any top-level type key from the object so it is read as label->items pairs.","Inspect the place token in the message (it names the sidebar / category / items slice) to locate the exact malformed node, then fix that node's shape.","Validate the sidebars export against the documented shapes at https://docusaurus.io/docs/sidebar/items before rebuilding."],"exampleFix":"// before: object with type where array expected\nconst sidebars = {\n  tutorial: {type: 'category', label: 'Tutorial', items: ['intro']},\n};\n\n// after: array of items\nconst sidebars = {\n  tutorial: [{type: 'category', label: 'Tutorial', items: ['intro']}],\n};","handlingStrategy":"type-guard","validationCode":"const {isCategoriesShorthand} = require('@docusaurus/plugin-content-docs/lib/sidebars/utils');\nfunction isValidSidebarRoot(node) {\n  return Array.isArray(node) || isCategoriesShorthand(node);\n}\n// Throw with a helpful message before the build does.\nObject.entries(sidebars).forEach(([name, node]) => {\n  if (!isValidSidebarRoot(node)) {\n    throw new Error(`Sidebar '${name}' must be an array or a categories shorthand object.`);\n  }\n});","typeGuard":"function isCategoriesShorthand(node) {\n  return (\n    typeof node === 'object' &&\n    node !== null &&\n    !Array.isArray(node) &&\n    !('type' in node)\n  );\n}\nfunction isValidSidebar(node) {\n  return Array.isArray(node) || isCategoriesShorthand(node);\n}","tryCatchPattern":null,"preventionTips":["Always wrap single sidebar items in an array.","Keep the shorthand notation free of any top-level type property.","Use the official sidebars types from @docusaurus/plugin-content-docs for TypeScript-checked configs."],"tags":["docs","sidebar","configuration","validation"],"backgroundTag":null,"analyzedSha":"3f483e80e326cc646b54b83d564b3f0c4881b9a6","analyzedAt":"2026-08-12T13:25:04.382Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}