{"record":{"id":"bb0192827509a36b","repo":"abhigyanpatwari/GitNexus","slug":"no-source-files-found-in-the-knowledge-graph-noth","errorCode":null,"errorMessage":"No source files found in the knowledge graph. Nothing to document.","messagePattern":"No source files found in the knowledge graph\\. Nothing to document\\.","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/wiki/generator.ts","lineNumber":359,"sourceCode":"    this.onProgress('html', 98, 'Building HTML viewer...');\n    const repoName = path.basename(this.repoPath);\n    await generateHTMLViewer(this.wikiDir, repoName);\n  }\n\n  // ─── Full Generation ────────────────────────────────────────────────\n\n  private async fullGeneration(currentCommit: string): Promise<WikiRunResult> {\n    let pagesGenerated = 0;\n\n    // Phase 0: Gather structure\n    this.onProgress('gather', 5, 'Querying graph for file structure...');\n    const filesWithExports = await getFilesWithExports();\n    const allFiles = await getAllFiles();\n\n    // Filter to source files only\n    const sourceFiles = allFiles.filter((f) => !shouldIgnorePath(f));\n    if (sourceFiles.length === 0) {\n      throw new Error('No source files found in the knowledge graph. Nothing to document.');\n    }\n\n    // Build enriched file list (merge exports into all source files)\n    const exportMap = new Map(filesWithExports.map((f) => [f.filePath, f]));\n    const enrichedFiles: FileWithExports[] = sourceFiles.map((fp) => {\n      return exportMap.get(fp) || { filePath: fp, symbols: [] };\n    });\n\n    this.onProgress('gather', 10, `Found ${sourceFiles.length} source files`);\n\n    // Phase 1: Build module tree\n    const moduleTree = await this.buildModuleTree(enrichedFiles);\n    pagesGenerated = 0;\n\n    // If reviewOnly mode, save tree and stop for user to review/edit\n    if (this.options.reviewOnly) {\n      await this.saveModuleTree(moduleTree);\n      this.onProgress('review', 30, 'Module tree ready for review');","sourceCodeStart":341,"sourceCodeEnd":377,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/52924ef12c2290ceee4612526a828ec4cdf2047f/gitnexus/src/core/wiki/generator.ts#L341-L377","documentation":"During full wiki generation the generator queries the LadybugDB knowledge graph for all files, filters out ignored paths via shouldIgnorePath, and throws if zero source files remain. It is a precondition failure: the wiki pipeline documents source files, so an empty (or all-ignored) graph means there is nothing to document and continuing would produce an empty wiki.","triggerScenarios":"Running `gitnexus wiki` before `gitnexus analyze` has indexed the repo; running it against the wrong working directory (no index there); the index only contains files excluded by shouldIgnorePath (build output, vendored dirs, docs-only trees); a corrupt or wiped LadybugDB database.","commonSituations":"Fresh clone where the user runs the wiki command first; running from a subdirectory that is not the indexed repo root; index built in a previous CI job but not present locally; path-ignore rules (or a .gitnexus ignore config) that exclude the whole tree.","solutions":["Index the repo first: `gitnexus analyze` from the repo root, then rerun `gitnexus wiki`","Verify the index actually has files: `gitnexus status` (or `gitnexus query` for any symbol) to confirm the graph is non-empty","Check that you are running in the same directory that was indexed and that ignore rules are not excluding every source file","If the index is corrupt/empty, rebuild it (`gitnexus clean` then `gitnexus analyze`)"],"exampleFix":"# before\ngitnexus wiki   # ERROR: No source files found\n\n# after\ngitnexus analyze\ngitnexus wiki","handlingStrategy":"validation","validationCode":"// Run before wiki generation:\nimport { execFileSync } from 'child_process';\nconst status = JSON.parse(execFileSync('gitnexus', ['status', '--json'], { encoding: 'utf8' }));\nif (!status.symbols || status.symbols === 0) {\n  throw new Error('Index empty — run `gitnexus analyze` before generating the wiki');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await generator.generate();\n} catch (err) {\n  if (err instanceof Error && err.message.includes('No source files found')) {\n    await runAnalyze(); // build the index, then retry once\n    return generator.generate();\n  }\n  throw err;\n}","preventionTips":["Always run `gitnexus analyze` (or confirm `gitnexus status` shows symbols) before `gitnexus wiki`","Run the CLI from the repo root that owns the .gitnexus index","In automation, add an index-exists check (or `gitnexus status`) as a pre-wiki step"],"tags":["wiki","knowledge-graph","empty-index","gitnexus"],"backgroundTag":"empty-index","analyzedSha":"52924ef12c2290ceee4612526a828ec4cdf2047f","analyzedAt":"2026-08-20T23:29:22.980Z","contentChangedAt":"2026-08-20T23:29:22.980Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}