{"record":{"id":"da9c0dfaad4408d3","repo":"abhigyanpatwari/GitNexus","slug":"wiki-was-generated-in-prevdisplay-use-force","errorCode":null,"errorMessage":"Wiki was generated in ${prevDisplay}; use --force to regenerate in ${nextDisplay}.","messagePattern":"Wiki was generated in (.+?); use --force to regenerate in (.+?)\\.","errorType":"validation","errorClass":"Error","httpStatus":null,"severity":"info","filePath":"gitnexus/src/core/wiki/generator.ts","lineNumber":268,"sourceCode":"\n  /**\n   * Main entry point. Runs the full pipeline or incremental update.\n   */\n  async run(): Promise<WikiRunResult> {\n    await fs.mkdir(this.wikiDir, { recursive: true });\n\n    const existingMeta = await this.loadWikiMeta();\n    const currentCommit = this.getCurrentCommit();\n    const forceMode = this.options.force;\n\n    // Up-to-date check (skip if --force)\n    if (!forceMode && existingMeta && existingMeta.fromCommit === currentCommit) {\n      const currentLang = this.effectiveLang();\n      const metaLang = existingMeta.lang ?? '';\n      if (currentLang !== metaLang) {\n        const prevDisplay = metaLang || 'english (default)';\n        const nextDisplay = currentLang || 'english (default)';\n        throw new Error(\n          `Wiki was generated in ${prevDisplay}; use --force to regenerate in ${nextDisplay}.`,\n        );\n      }\n      // Still regenerate the HTML viewer in case it's missing\n      await this.ensureHTMLViewer();\n      return { pagesGenerated: 0, mode: 'up-to-date', failedModules: [] };\n    }\n\n    // Force mode: delete snapshot to force full re-grouping\n    if (forceMode) {\n      try {\n        await fs.unlink(path.join(this.wikiDir, 'first_module_tree.json'));\n      } catch {}\n      // Delete existing module pages so they get regenerated\n      const existingFiles = await fs.readdir(this.wikiDir).catch(() => [] as string[]);\n      for (const f of existingFiles) {\n        if (f.endsWith('.md')) {\n          try {","sourceCodeStart":250,"sourceCodeEnd":286,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/d540b00184d71a896261ee02670da9a92d59d8f7/gitnexus/src/core/wiki/generator.ts#L250-L286","documentation":"Thrown during wiki generation's up-to-date check (first site, before DB initialization) when the wiki was already generated for the current commit but in a different language than the effective language of this run. The check is skipped when `--force` is set. This prevents silently overwriting a wiki generated in one language with content in another without explicit consent.","triggerScenarios":"`!forceMode && existingMeta && existingMeta.fromCommit === currentCommit` and `this.effectiveLang() !== existingMeta.lang`. The existing wiki metadata records a different language than the current run's resolved language (which defaults to English or respects a `--lang` flag).","commonSituations":"Generated a wiki in English, then ran `gitnexus wiki --lang japanese` on the same commit without `--force`; or the `GITNEXUS_WIKI_LANG` env var changed between runs on an unchanged repo.","solutions":["Add `--force` to regenerate the wiki in the new language: `gitnexus wiki --force`.","Or switch back to the language the wiki was generated in (shown in the error as `prevDisplay`)."],"exampleFix":"# before\ngitnexus wiki --lang japanese\n# error: Wiki was generated in english (default); use --force to regenerate in japanese.\n# after\ngitnexus wiki --lang japanese --force","handlingStrategy":"validation","validationCode":"// Before wiki generation, check if a language change is needed:\nconst meta = await loadWikiMeta();\nif (meta && meta.fromCommit === currentCommit && meta.lang !== desiredLang) {\n  console.log(`Wiki exists in ${meta.lang}. Pass --force to regenerate in ${desiredLang}.`);\n  // either add --force or abort\n}","typeGuard":"const needsForceForLanguageChange = (\n  meta: WikiMeta | undefined,\n  currentCommit: string,\n  desiredLang: string,\n): boolean =>\n  !!meta &&\n  meta.fromCommit === currentCommit &&\n  (meta.lang ?? '') !== (desiredLang ?? '');","tryCatchPattern":"try {\n  await generator.generate();\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith('Wiki was generated in')) {\n    console.error('Add --force to regenerate in the new language.');\n  }\n  throw err;\n}","preventionTips":["Always pass `--force` when intentionally changing the wiki language on the same commit.","Pin the wiki language in `.gitnexusrc` to avoid accidental language mismatches."],"tags":["wiki","language","config","idempotency"],"backgroundTag":null,"analyzedSha":"d540b00184d71a896261ee02670da9a92d59d8f7","analyzedAt":"2026-08-12T19:50:25.132Z","schemaVersion":2},"datasetVersion":"2026-08-13T04:17:16.726Z"}