{"record":{"id":"0d9f9f1bcd3d1c9c","repo":"marktext/marktext","slug":"no-pages-registered-for-tab-tab","errorCode":null,"errorMessage":"No pages registered for tab \"${tab}\"","messagePattern":"No pages registered for tab \"(.+?)\"","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"packages/website/src/lib/docs-nav.ts","lineNumber":161,"sourceCode":"\n/** prev / next page in the flat ordered list. */\nexport function neighborsFor(slug: string[]): {\n  prev: DocPageWithCtx | null\n  next: DocPageWithCtx | null\n} {\n  const entry = PAGE_BY_KEY.get(slug.join('/'))\n  if (!entry) return { prev: null, next: null }\n  const { index } = entry\n  return {\n    prev: index > 0 ? ALL_PAGES[index - 1] : null,\n    next: index < ALL_PAGES.length - 1 ? ALL_PAGES[index + 1] : null\n  }\n}\n\n/** First page of a given tab — used for `/docs` redirect and tab switch fallback. */\nexport function firstPageOfTab(tab: DocTabId): DocPageWithCtx {\n  const p = ALL_PAGES.find((page) => page.tab === tab)\n  if (!p) throw new Error(`No pages registered for tab \"${tab}\"`)\n  return p\n}\n","sourceCodeStart":143,"sourceCodeEnd":164,"githubUrl":"https://github.com/marktext/marktext/blob/e52106fd1cdcbd33c1258b7b0cdc7013c4c5d86c/packages/website/src/lib/docs-nav.ts#L143-L164","documentation":"Thrown by firstPageOfTab() in the website docs-nav module when ALL_PAGES contains no page whose `tab` equals the requested DocTabId. ALL_PAGES is built at module load from DOC_TABS ('user' | 'dev'); the function is used by the /docs redirect and tab-switch fallback to find the first page of a tab.","triggerScenarios":"firstPageOfTab called with a DocTabId ('user' or 'dev') whose DOC_TABS entry has an empty groups[].pages array; a tab id passed that is not present in DOC_TABS at all (type cast around the union).","commonSituations":"A docs content edit removed all pages from a tab but left the tab id referenced by a redirect. A new DocTabId value added to the type union before pages are registered. A refactor of DOC_TABS that leaves a tab with zero groups.","solutions":["Ensure every DocTab in DOC_TABS has at least one group with at least one page.","Guard the call: const p = ALL_PAGES.find(...); return p ?? ALL_PAGES[0] to avoid crashing the redirect.","Run the docs build (`pnpm --filter marktext-website build`) which exercises the nav and surfaces the regression.","Keep the DocTabId type in sync with DOC_TABS ids so no unregistered tab id is callable."],"exampleFix":"// before\nexport function firstPageOfTab(tab: DocTabId): DocPageWithCtx {\n  const p = ALL_PAGES.find((page) => page.tab === tab)\n  if (!p) throw new Error(`No pages registered for tab \"${tab}\"`)\n  return p\n}\n// after\nexport function firstPageOfTab(tab: DocTabId): DocPageWithCtx {\n  const p = ALL_PAGES.find((page) => page.tab === tab)\n  if (!p) throw new Error(`No pages registered for tab \"${tab}\". Add at least one page to DOC_TABS for this tab.`)\n  return p\n}","handlingStrategy":"validation","validationCode":"function tabHasPages(tab: DocTabId): boolean {\n  return ALL_PAGES.some((p) => p.tab === tab)\n}","typeGuard":"function tabHasPages(tab: DocTabId): boolean {\n  return ALL_PAGES.some((p) => p.tab === tab)\n}","tryCatchPattern":null,"preventionTips":["Keep every DOC_TABS entry populated with at least one page.","Add a unit test asserting each DocTabId has >=1 page in ALL_PAGES.","Sync the DocTabId union with DOC_TABS ids.","Guard firstPageOfTab callers against the throw."],"tags":["website","docs","navigation","config"],"backgroundTag":null,"analyzedSha":"e52106fd1cdcbd33c1258b7b0cdc7013c4c5d86c","analyzedAt":"2026-08-12T13:58:32.443Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}