abhigyanpatwari/GitNexus · error
LadybugDB not initialized for repo
Error message
LadybugDB not initialized for repo "${repoId}". Call initLbug first. What it means
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.
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
Example fix
// before — throws when the pool entry was never registered (or was evicted)
const rows = await executeParameterized(repoId, cypher, params);
// after — re-init lazily so the pool entry exists
if (!isLbugReady(repoId)) {
await initLbug(repoId, dbPath);
}
const rows = await executeParameterized(repoId, cypher, params); Defensive patterns
Strategy: validation
Validate before calling
// guard every query entry point
import { isLbugReady, initLbug } from '../core/lbug/pool-adapter.js';
if (!isLbugReady(repoId)) {
await initLbug(repoId, dbPath);
} Type guard
const isNotInitializedForRepo = (e: unknown): boolean =>
e instanceof Error &&
e.message.startsWith('LadybugDB not initialized for repo') ; Try / catch
try {
rows = await executeParameterized(repoId, cypher, params);
} catch (e) {
if (isNotInitializedForRepo(e)) {
// init was skipped, closed, or the repo was LRU-evicted — re-init once and retry
await initLbug(repoId, dbPath);
rows = await executeParameterized(repoId, cypher, params);
} else {
throw e;
}
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Batch execution failed for rows
- Connection pool integrity error: expected
- Failed to remove the LadybugDB index files — still present…
- FTS extension unavailable - cannot create FTS index
- FTS index ' ' on table exists but the LadybugDB FTS…
AI-assisted analysis of abhigyanpatwari/GitNexus@ac9a4e9abd (2026-08-20).
Data as JSON: /api/errors/9f7128920a581e55.
Report an issue: GitHub.
Appendix: source
Thrown at gitnexus/src/core/lbug/pool-adapter.ts:1129
if (state === 'backtick') {
if (ch === '`' && next === '`') {
backtickIdentifier += '`';
code += ' ';
i++;
} else if (ch === '`') {
state = 'code';
code +=
backtickIdentifier.toUpperCase() === 'QUERY_VECTOR_INDEX' ? 'QUERY_VECTOR_INDEX' : ' ';
} else if (ch === '\\' && next !== undefined) {
backtickIdentifier += next;
code += ' ';
i++;
} else {
backtickIdentifier += ch;
code += ch === '\n' || ch === '\r' ? ch : ' ';
}
continue;
}
if (ch === '\\') {
code += ' ';
if (next !== undefined) {
code += next === '\n' || next === '\r' ? next : ' ';
i++;
}
continue;
}
const closesLiteral = (state === 'single' && ch === "'") || (state === 'double' && ch === '"');
if (closesLiteral) state = 'code';
code += ch === '\n' || ch === '\r' ? ch : ' ';
}
return /\bCALL\s+QUERY_VECTOR_INDEX\s*\(/i.test(code);
}
View on GitHub (pinned to ac9a4e9abd)