{"record":{"id":"243993798687ae04","repo":"facebook/docusaurus","slug":"couldn-t-find-any-doc-with-id-docid-in-versio","errorCode":null,"errorMessage":"Couldn't find any doc with id \"${docId}\" in version${versions.length > 1 ? 's' : ''} \"${versions.map((version) => version.name).join(', ')}\".\nAvailable doc ids are:\n- ${uniq(allDocs.map((versionDoc) => versionDoc.id)).join('\\n- ')}","messagePattern":"Couldn't find any doc with id \"(.+?)\" in version(.+?) \"(.+?)\"\\.\nAvailable doc ids are:\n- (.+?)","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/docusaurus-plugin-content-docs/src/client/docsUtils.tsx","lineNumber":369,"sourceCode":" * @throws This hook throws if a doc with said ID is not found.\n */\nexport function useLayoutDoc(\n  docId: string,\n  docsPluginId?: string,\n): GlobalDoc | null {\n  const versions = useDocsVersionCandidates(docsPluginId);\n  return useMemo(() => {\n    const allDocs = versions.flatMap((version) => version.docs);\n    const doc = allDocs.find((versionDoc) => versionDoc.id === docId);\n    if (!doc) {\n      const isDraft = versions\n        .flatMap((version) => version.draftIds)\n        .includes(docId);\n      // Drafts should be silently filtered instead of throwing\n      if (isDraft) {\n        return null;\n      }\n      throw new Error(\n        `Couldn't find any doc with id \"${docId}\" in version${\n          versions.length > 1 ? 's' : ''\n        } \"${versions.map((version) => version.name).join(', ')}\".\nAvailable doc ids are:\n- ${uniq(allDocs.map((versionDoc) => versionDoc.id)).join('\\n- ')}`,\n      );\n    }\n    return doc;\n  }, [docId, versions]);\n}\n\n// TODO later read version/route directly from context\n/**\n * The docs plugin creates nested routes, with the top-level route providing the\n * version metadata, and the subroutes creating individual doc pages. This hook\n * will match the current location against all known sub-routes.\n *\n * @param props The props received by `@theme/DocRoot`","sourceCodeStart":351,"sourceCodeEnd":387,"githubUrl":"https://github.com/facebook/docusaurus/blob/3f483e80e326cc646b54b83d564b3f0c4881b9a6/packages/docusaurus-plugin-content-docs/src/client/docsUtils.tsx#L351-L387","documentation":"Thrown by useLayoutDoc() when no doc with the given docId exists in any candidate version AND the id is not a draft. It searches all docs across versions (active + preferred + latest via useDocsVersionCandidates); a miss first checks whether the id is a draft (draftIds), in which case it returns null silently (drafts are intentionally filtered). Only non-draft, non-existent ids throw, and the message lists all available doc ids to help correct the reference. Like useLayoutDocsSidebar, this is for layout components that resolve a doc link from any page.","triggerScenarios":"A navbar item, footer link, or layout component references a docId that was renamed, deleted, or never existed; the doc exists only in a different docs plugin id; a typo in the docId string. The throw is inside useMemo so it fires during render of the layout component.","commonSituations":"Renaming a doc (changing its id/slug) without updating config references; deleting a doc while navbar still links to its id; docsPluginId mismatch when multiple docs plugins are configured; referencing a doc that exists only in an older non-candidate version.","solutions":["Read the 'Available doc ids' list in the error and correct the docId to a valid one.","Search the docs (including versioned_docs) for the exact id string to confirm spelling/slashes.","If the doc is in a different docs plugin, pass the right docsPluginId to useLayoutDoc.","If the doc was intentionally removed, delete the stale navbar/layout reference too."],"exampleFix":"// before\nnavbar: [{ to: '/docs/intro', label: 'Intro', docId: 'introo' }]\n// after: fix the typo\nnavbar: [{ to: '/docs/intro', label: 'Intro', docId: 'intro' }]","handlingStrategy":"validation","validationCode":"import {useDocsVersionCandidates} from '@docusaurus/plugin-content-docs/client';\n\nfunction useKnownDocId(docId: string, docsPluginId?: string) {\n  const versions = useDocsVersionCandidates(docsPluginId);\n  const allIds = versions.flatMap((v) => v.docs.map((d) => d.id));\n  const isDraft = versions.flatMap((v) => v.draftIds).includes(docId);\n  return {exists: allIds.includes(docId), isDraft, available: allIds} as const;\n}\n// const check = useKnownDocId('intro'); if (!check.exists && !check.isDraft) return null;","typeGuard":"const isKnownDocId = (\n  id: string,\n  versions: {docs: {id: string}[]; draftIds: string[]}[],\n): boolean => versions.some((v) => v.docs.some((d) => d.id === id));","tryCatchPattern":null,"preventionTips":["Validate docId against version docs before referencing in navbar/layout.","Update all references when renaming or deleting a doc.","Remember drafts return null silently — only real misses throw."],"tags":["docs","navbar","versioning","doc-id","config"],"backgroundTag":null,"analyzedSha":"3f483e80e326cc646b54b83d564b3f0c4881b9a6","analyzedAt":"2026-08-12T13:25:04.382Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}