{"record":{"id":"0fc4ad8def5b484b","repo":"abhigyanpatwari/GitNexus","slug":"cannot-repair-fts-indexes-graph-store-at-lbugpa-0fc4ad","errorCode":null,"errorMessage":"Cannot repair FTS indexes: graph store at ${lbugPath} is ${foundType} (expected a file). Run `gitnexus analyze` (full) to rebuild from scratch.","messagePattern":"Cannot repair FTS indexes: graph store at (.+?) is (.+?) \\(expected a file\\)\\. Run `gitnexus analyze` \\(full\\) to rebuild from scratch\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/run-analyze.ts","lineNumber":1154,"sourceCode":"        `Cannot repair FTS indexes: graph store at ${lbugPath} is missing. ` +\n          'Run `gitnexus analyze` (full) to rebuild from scratch.',\n      );\n    }\n    if (!lbugStat.isFile()) {\n      const foundType = lbugStat.isDirectory()\n        ? 'a directory'\n        : lbugStat.isSymbolicLink()\n          ? 'a symbolic link'\n          : lbugStat.isSocket()\n            ? 'a socket'\n            : lbugStat.isBlockDevice()\n              ? 'a block device'\n              : lbugStat.isCharacterDevice()\n                ? 'a character device'\n                : lbugStat.isFIFO()\n                  ? 'a FIFO'\n                  : 'not a regular file';\n      throw new Error(\n        `Cannot repair FTS indexes: graph store at ${lbugPath} is ${foundType} (expected a file). ` +\n          'Run `gitnexus analyze` (full) to rebuild from scratch.',\n      );\n    }\n    try {\n      await initLbug(lbugPath);\n      // Gate on FTS availability BEFORE touching any index. createSearchFTSIndexes\n      // now DROPs each index before recreating it (so schema changes reach existing\n      // DBs); if the extension were unavailable, the drops would run and leave the\n      // DB index-less, only failing at the create step. Fail loudly first — mirrors\n      // the analyze path's `if (ftsAvailable)` gate below — so an unavailable\n      // extension never destroys the existing indexes.\n      const repairFtsAvailable = await loadFTSExtension(undefined, {\n        policy: resolveAnalyzeInstallPolicy(),\n      });\n      if (!repairFtsAvailable) {\n        // Surface the load-side reason (#2374): \"not pre-installed\" was wrong\n        // and doctor never installed anything, so the old message trapped","sourceCodeStart":1136,"sourceCodeEnd":1172,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/gitnexus/src/core/run-analyze.ts#L1136-L1172","documentation":"Thrown during `--repair-fts` when `fs.lstat(lbugPath)` succeeds but the entry is not a regular file — it is a directory, symbolic link, socket, block/character device, FIFO, or other special file type. The LadybugDB graph store must be a single regular file; a non-file entry at that path indicates filesystem corruption, accidental directory creation, or a stray symlink, any of which would cause the database layer to malfunction if opened.","triggerScenarios":"`lbugStat.isFile()` returns false after a successful `lstat`. The found type is classified into a human-readable string (directory, symbolic link, socket, block device, character device, FIFO, or 'not a regular file').","commonSituations":"Someone manually created a directory named after the DB file (e.g. `mkdir .gitnexus/store.lbug`), a symlink was left pointing to a moved/deleted store, or a backup restore placed a directory where a file should be.","solutions":["Remove the non-file entry at the reported path (e.g. `rm -rf <lbugPath>` if it's a directory).","Run `gitnexus analyze` (full) to rebuild the graph store as a proper file.","If the path is a symlink, verify where it points and either fix the target or remove the symlink before re-analyzing."],"exampleFix":"// before\n// .gitnexus/store.lbug is a directory or symlink → repair-fts fails\n// after\nrm -rf .gitnexus/store.lbug\ngitnexus analyze               // creates a proper regular file\ngitnexus analyze --repair-fts","handlingStrategy":"validation","validationCode":"// Before repair-fts, verify lbugPath is a regular file:\nimport { stat } from 'fs/promises';\nconst s = await stat(lbugPath);\nif (!s.isFile()) {\n  console.error(`Expected a regular file at ${lbugPath}, got a different file type.`);\n  process.exit(1);\n}","typeGuard":"import { stat } from 'fs/promises';\nconst isRegularFile = async (p: string): Promise<boolean> => {\n  try { return (await stat(p)).isFile(); } catch { return false; }\n};","tryCatchPattern":"try {\n  await runAnalyze({ ...options, repairFts: true });\n} catch (err) {\n  if (err instanceof Error && err.message.includes('expected a file')) {\n    console.error('Remove the non-file entry and run `gitnexus analyze` to rebuild.');\n  }\n  throw err;\n}","preventionTips":["Never create directories or symlinks at the graph store path.","After restoring from backup, verify `.gitnexus/` contains regular files, not directories."],"tags":["fts","analyze","filesystem","graph-store","corruption"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}