{"record":{"id":"a89996115600295b","repo":"facebook/docusaurus","slug":"no-version-doc-found-by-id-id","errorCode":null,"errorMessage":"no version doc found by id=${id}","messagePattern":"no version doc found by id=(.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/docusaurus-plugin-content-docs/src/client/docsUtils.tsx","lineNumber":49,"sourceCode":"  PropSidebarBreadcrumbsItem,\n} from '@docusaurus/plugin-content-docs';\n\n/**\n * A null-safe way to access a doc's data by ID in the active version.\n */\nexport function useDocById(id: string): PropVersionDoc;\n/**\n * A null-safe way to access a doc's data by ID in the active version.\n */\nexport function useDocById(id: string | undefined): PropVersionDoc | undefined;\nexport function useDocById(id: string | undefined): PropVersionDoc | undefined {\n  const version = useDocsVersion();\n  if (!id) {\n    return undefined;\n  }\n  const doc = version.docs[id];\n  if (!doc) {\n    throw new Error(`no version doc found by id=${id}`);\n  }\n  return doc;\n}\n\n/**\n * Pure function, similar to `Array#find`, but works on the sidebar tree.\n */\nexport function findSidebarCategory(\n  sidebar: PropSidebar,\n  predicate: (category: PropSidebarItemCategory) => boolean,\n): PropSidebarItemCategory | undefined {\n  for (const item of sidebar) {\n    if (item.type === 'category') {\n      if (predicate(item)) {\n        return item;\n      }\n      const subItem = findSidebarCategory(item.items, predicate);\n      if (subItem) {","sourceCodeStart":31,"sourceCodeEnd":67,"githubUrl":"https://github.com/facebook/docusaurus/blob/3f483e80e326cc646b54b83d564b3f0c4881b9a6/packages/docusaurus-plugin-content-docs/src/client/docsUtils.tsx#L31-L67","documentation":"Thrown by useDocById() when the current docs version's docs map has no entry for the given id. The hook first calls useDocsVersion() to get the active version, then indexes version.docs[id]; a miss throws. An undefined id returns undefined early (null-safe overload), so this throw specifically means a non-empty id that doesn't match any doc in the current version.","triggerScenarios":"Passing a doc id from a sidebar config or cross-reference that doesn't exist in the active version (typo, renamed doc, or doc only present in another version); referencing a doc id after a doc was deleted or its id changed.","commonSituations":"Renaming a doc's slug/id but leaving stale `docId` references in sidebars.json or navbar items; versioned setups where the id exists in version X but the active version is Y; cross-version links pointing at ids not present in the current version.","solutions":["Verify the id exists in the current version: search version docs for that exact id string (case/slash-sensitive).","Fix stale references in sidebars config / navbar / doc cards to the renamed or correct id.","If the doc was moved to another version, use a version-aware lookup (useLayoutDoc) or a permalink instead.","If id may legitimately be absent, use the null-safe overload: pass `undefined` to short-circuit, or pre-check before calling."],"exampleFix":"// before\nconst doc = useDocById('tutorial/basics'); // typo, real id is 'tutorial/intro'\n// after\nconst doc = useDocById('tutorial/intro');","handlingStrategy":"validation","validationCode":"import {useDocsVersion} from '@docusaurus/plugin-content-docs/client';\n\nfunction useDocByIdSafe(id: string | undefined) {\n  const version = useDocsVersion();\n  if (!id || !(id in version.docs)) return undefined;\n  return version.docs[id];\n}\n// use useDocByIdSafe() instead of useDocById() when absence is acceptable","typeGuard":"const isKnownDocId = (\n  id: string,\n  docs: Record<string, unknown>,\n): id is keyof typeof docs => id in docs;","tryCatchPattern":null,"preventionTips":["Validate docId against version.docs before calling useDocById when absence is possible.","Use the undefined overload (pass undefined) to short-circuit for optional ids.","Update all sidebar/navbar references when renaming a doc id."],"tags":["docs","versioning","doc-id","react-hook"],"backgroundTag":null,"analyzedSha":"3f483e80e326cc646b54b83d564b3f0c4881b9a6","analyzedAt":"2026-08-12T13:25:04.382Z","schemaVersion":2},"datasetVersion":"2026-08-12T18:17:37.767Z"}