{"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":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/wiki/generator.ts","lineNumber":276,"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":258,"sourceCodeEnd":294,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/52924ef12c2290ceee4612526a828ec4cdf2047f/gitnexus/src/core/wiki/generator.ts#L258-L294","documentation":"WikiGenerator persists metadata (wikiDir/meta.json with fromCommit and lang) next to the generated wiki. On the up-to-date fast path (existing meta.fromCommit equals the current commit), it compares the requested output language (options.lang, '' meaning English default) against the language the wiki was generated in. When they differ it throws instead of silently returning 'up-to-date', because the existing pages are in the wrong language and only a full regeneration can switch it.","triggerScenarios":"Running `gitnexus wiki` (WikiGenerator.generate()) without --force when a wiki already exists for the current HEAD commit and meta.lang differs from the effective --lang value, e.g. wiki generated with `--lang japanese` then rerun with `--lang german` or with no --lang after a non-English run.","commonSituations":"Switching wiki language on a repo whose wiki is already up to date; a teammate generated the wiki with a different --lang default; CI re-running the wiki command with a lang option that differs from the cached artifact; reverting from a translated wiki back to English.","solutions":["Rerun with --force to regenerate all pages in the new language: `gitnexus wiki --force --lang <lang>`","Or drop/change the --lang flag so it matches the language the existing wiki was generated in (message names both, e.g. 'japanese' vs 'english (default)')","Or delete the wiki output directory (containing meta.json) to discard the old-language wiki and rerun without --force"],"exampleFix":"# before\ngitnexus wiki --lang japanese   # wiki was generated in english\n\n# after\ngitnexus wiki --lang japanese --force","handlingStrategy":"try-catch","validationCode":"// Before calling generate(), compare persisted language with the requested one:\nimport fs from 'fs/promises';\nconst meta = await fs.readFile(`${wikiDir}/meta.json`, 'utf8')\n  .then(JSON.parse).catch(() => null);\nconst currentLang = normalizeLang(options.lang ?? ''); // '' = english default\nif (meta?.fromCommit === currentCommit && (meta.lang ?? '') !== currentLang) {\n  options = { ...options, force: true }; // pre-empt the guard\n}","typeGuard":null,"tryCatchPattern":"try {\n  const result = await generator.generate();\n} catch (err) {\n  if (err instanceof Error && err.message.startsWith('Wiki was generated in ')) {\n    // Re-run with force: full regeneration in the new language\n    return generatorWithForce.generate();\n  }\n  throw err;\n}","preventionTips":["Keep --lang consistent between wiki runs, or script it to always pass --force when the language changes","In CI, decide once whether wikis are translated and pin that --lang value","Read wikiDir/meta.json (fields fromCommit/lang) before running to detect a pending language switch"],"tags":["wiki","language","cache-mismatch","gitnexus"],"backgroundTag":"configuration-mismatch","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"}