{"record":{"id":"9f7128920a581e55","repo":"abhigyanpatwari/GitNexus","slug":"ladybugdb-not-initialized-for-repo-repoid-ca","errorCode":null,"errorMessage":"LadybugDB not initialized for repo \"${repoId}\". Call initLbug first.","messagePattern":"LadybugDB not initialized for repo \"(.+?)\"\\. Call initLbug first\\.","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gitnexus/src/core/lbug/pool-adapter.ts","lineNumber":1129,"sourceCode":"    if (state === 'backtick') {\n      if (ch === '`' && next === '`') {\n        backtickIdentifier += '`';\n        code += '  ';\n        i++;\n      } else if (ch === '`') {\n        state = 'code';\n        code +=\n          backtickIdentifier.toUpperCase() === 'QUERY_VECTOR_INDEX' ? 'QUERY_VECTOR_INDEX' : ' ';\n      } else if (ch === '\\\\' && next !== undefined) {\n        backtickIdentifier += next;\n        code += '  ';\n        i++;\n      } else {\n        backtickIdentifier += ch;\n        code += ch === '\\n' || ch === '\\r' ? ch : ' ';\n      }\n      continue;\n    }\n\n    if (ch === '\\\\') {\n      code += ' ';\n      if (next !== undefined) {\n        code += next === '\\n' || next === '\\r' ? next : ' ';\n        i++;\n      }\n      continue;\n    }\n\n    const closesLiteral = (state === 'single' && ch === \"'\") || (state === 'double' && ch === '\"');\n    if (closesLiteral) state = 'code';\n    code += ch === '\\n' || ch === '\\r' ? ch : ' ';\n  }\n\n  return /\\bCALL\\s+QUERY_VECTOR_INDEX\\s*\\(/i.test(code);\n}\n","sourceCodeStart":1111,"sourceCodeEnd":1147,"githubUrl":"https://github.com/abhigyanpatwari/GitNexus/blob/ac9a4e9abd8fd3058c070b72c23402a4f887929a/gitnexus/src/core/lbug/pool-adapter.ts#L1111-L1147","documentation":"executeParameterized (gitnexus/src/core/lbug/pool-adapter.ts:1033): no pool entry is registered for repoId — initLbug was never called (or not awaited) for this repo, or the entry was closed / LRU-evicted since. The pool registers entries LAST so callers see either 'not initialized' or a fully ready pool, never a half-built one.","triggerScenarios":"Calling executeQuery/executeParameterized(repoId, ...) before awaiting initLbug(repoId, dbPath); using a repoId string that differs from the one initLbug registered; querying after closeLbug(repoId) or after long-idle LRU eviction without re-initializing.","commonSituations":"Startup races where queries fire before the init promise resolves; repoId normalization mismatches (owner/name vs path forms); long-idle repos evicted by the LRU and queried again without re-init.","solutions":["Await initLbug(repoId, dbPath) before the first query, and re-init after closeLbug or long idle periods","Use the exact same repoId string for init and queries — check the mapping/normalization once","If the underlying index is missing you will also see 'LadybugDB not found' — run gitnexus analyze first","Guard call sites with isLbugReady(repoId) and re-init lazily when it returns false"],"exampleFix":"// before — throws when the pool entry was never registered (or was evicted)\nconst rows = await executeParameterized(repoId, cypher, params);\n\n// after — re-init lazily so the pool entry exists\nif (!isLbugReady(repoId)) {\n  await initLbug(repoId, dbPath);\n}\nconst rows = await executeParameterized(repoId, cypher, params);","handlingStrategy":"validation","validationCode":"// guard every query entry point\nimport { isLbugReady, initLbug } from '../core/lbug/pool-adapter.js';\nif (!isLbugReady(repoId)) {\n  await initLbug(repoId, dbPath);\n}","typeGuard":"const isNotInitializedForRepo = (e: unknown): boolean =>\n  e instanceof Error &&\n  e.message.startsWith('LadybugDB not initialized for repo') ;","tryCatchPattern":"try {\n  rows = await executeParameterized(repoId, cypher, params);\n} catch (e) {\n  if (isNotInitializedForRepo(e)) {\n    // init was skipped, closed, or the repo was LRU-evicted — re-init once and retry\n    await initLbug(repoId, dbPath);\n    rows = await executeParameterized(repoId, cypher, params);\n  } else {\n    throw e;\n  }\n}","preventionTips":["Await initLbug(repoId, dbPath) during startup before issuing any query","Use one canonical repoId normalization for both init and query call sites","Re-init after closeLbug or long idle periods — LRU eviction removes pool entries"],"tags":["gitnexus","ladybugdb","initialization","pool","usage-order"],"backgroundTag":"connection-not-initialized","analyzedSha":"ac9a4e9abd8fd3058c070b72c23402a4f887929a","analyzedAt":"2026-08-20T23:29:22.980Z","contentChangedAt":"2026-08-20T23:29:22.980Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}