{"record":{"id":"dafa22bda089b987","repo":"abhigyanpatwari/GitNexus","slug":"storage-version-mismatch-suggestion-msg-this-index-was","errorCode":null,"errorMessage":"${STORAGE_VERSION_MISMATCH_SUGGESTION} (${msg}) [This index was written by a different @ladybugdb/core build (a different storage version) than the one currently installed. Run `gitnexus analyze --force` on this repo to rebuild it with the current engine.]","messagePattern":"(.+?) \\((.+?)\\) \\[This index was written by a different @ladybugdb/core build \\(a different storage version\\) than the one currently installed\\. Run `gitnexus analyze --force` on this repo to rebuild it with the current engine\\.\\]","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/lbug/lbug-config.ts","lineNumber":586,"sourceCode":" *  newer engine, opened after downgrading the pinned dependency. Example:\n *  \"Runtime exception: Trying to read a database file with a different\n *  version. Database file version: 43, Current build storage version: 42\" */\nconst STORAGE_VERSION_MISMATCH_RE = /database file with a different version/i;\n\nexport const STORAGE_VERSION_MISMATCH_SUGGESTION =\n  'This index was written by a different @ladybugdb/core build (a different storage version) than the one currently installed. Run `gitnexus analyze --force` on this repo to rebuild it with the current engine.';\n\nexport function isStorageVersionMismatchError(err: unknown): boolean {\n  if (!err) return false;\n  const msg = err instanceof Error ? err.message : String(err);\n  return STORAGE_VERSION_MISMATCH_RE.test(msg);\n}\n\n/** Throws the rebuild-hint Error when `err` is a storage-version mismatch. */\nexport function throwIfStorageVersionMismatch(err: unknown): void {\n  if (!isStorageVersionMismatchError(err)) return;\n  const msg = err instanceof Error ? err.message : String(err);\n  throw new Error(`${STORAGE_VERSION_MISMATCH_SUGGESTION} (${msg})`);\n}\n\n// ─── Ladybug WAL checkpoint IO error matchers ───────────────────────────────\n//\n// Matched against LadybugDB v0.18.0 (see `gitnexus/package.json`\n// @ladybugdb/core). Strict regexes encode local_file_system.cpp wording\n// verified at that version. Two-tier strategy: strict matchers first so we\n// only fire on real checkpoint-rotation shapes; a permissive fallback\n// catches future Ladybug message drift so the recovery hint keeps surfacing\n// even if upstream wording changes.\n//\n// From Ladybug native LocalFileSystem exceptions (`local_file_system.cpp`),\n// surfaced in Node as:\n// \"Runtime exception: IO exception: Error renaming file ...\"\n// \"Runtime exception: IO exception: Error removing directory or file ...\"\n// We only match checkpoint-rotation shapes:\n//   - \"<db>.wal -> <db>.wal.checkpoint\" rename failures\n//   - \"<db>.wal.checkpoint\" remove failures","sourceCodeStart":568,"sourceCodeEnd":604,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/ac9a4e9abd8fd3058c070b72c23402a4f887929a/gitnexus/src/core/lbug/lbug-config.ts#L568-L604","documentation":"throwIfStorageVersionMismatch detects that a LadybugDB error is a storage-version mismatch — the index was written by a different @ladybugdb/core build than the one currently installed — and throws a rebuild-hint Error wrapping the original message. It is called by runSchemaCreationQueries and doInitLbug when opening an existing index.","triggerScenarios":"Opening a repo whose on-disk index was created by an older/newer @ladybugdb/core (e.g. after upgrading the gitnexus npm package or a lockfile bump changed the engine version) during init or schema-creation queries.","commonSituations":"Upgrading GitNexus and re-running analyze/serve against an old .gitnexus index; switching branches where package.json pins a different @ladybugdb/core; CI caching an index across engine upgrades.","solutions":["Run `gitnexus analyze --force` on the repo to rebuild the index with the current engine.","Alternatively delete the stored index (<repo>/.gitnexus/) and re-run `gitnexus analyze`.","If the old engine version is required, reinstall the matching @ladybugdb/core build instead of rebuilding."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  await initLbug(dbPath);\n} catch (err) {\n  try { throwIfStorageVersionMismatch(err); } catch (rebuildHint) {\n    console.error('Index built by a different engine; run: gitnexus analyze --force');\n    process.exitCode = 1;\n  }\n  throw err;\n}","preventionTips":["After upgrading GitNexus/@ladybugdb/core, plan for an index rebuild (analyze --force).","Do not cache .gitnexus index artifacts across CI runs with different engine versions.","Pin @ladybugdb/core versions consistently across environments that share an index."],"tags":["database","storage-version","index","upgrade"],"backgroundTag":"storage-version-mismatch","analyzedSha":"ac9a4e9abd8fd3058c070b72c23402a4f887929a","analyzedAt":"2026-09-15T23:29:44.066Z","contentChangedAt":"2026-09-15T23:29:44.066Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}