abhigyanpatwari/GitNexus · error · Error
LadybugDB not initialized for repo "${repoId}". Call initLbu
Error message
LadybugDB not initialized for repo "${repoId}". Call initLbug first. What it means
Thrown by executeParameterized when the pool has no entry for the given repoId. The pool is populated by doInitLbug → registered LAST (after FTS load, pre-warming) so that concurrent queries see either 'not initialized' or a fully ready pool. This error means initLbug was never called for this repo, or the pool entry was evicted (LRU) or explicitly closed. The error fires after a lightweight query-text warning check (warnIfQueryTextUnbounded) that never throws.
Source
Thrown at gitnexus/src/core/lbug/pool-adapter.ts:1033
/**
* Execute a parameterized query on a specific repo's connection pool.
* Uses prepare/execute pattern to prevent Cypher injection.
*/
export const executeParameterized = async (
repoId: string,
cypher: string,
params: Record<string, any>,
): Promise<any[]> => {
// A `.length` compare on text we already hold — runs before the pool lookup so
// a query built by splicing a caller-sized list names itself even when the
// repo is not initialized. Never throws (#2915).
warnIfQueryTextUnbounded(cypher, `pool executeParameterized (repo "${repoId}")`, (message) =>
poolSidecarLogger.warn(message),
);
const entry = pool.get(repoId);
if (!entry) {
throw new Error(`LadybugDB not initialized for repo "${repoId}". Call initLbug first.`);
}
entry.lastUsed = Date.now();
const conn = await checkout(entry);
silenceStdout();
activeQueryCount++;
let queryResult: lbug.QueryResult | lbug.QueryResult[] | undefined;
try {
const stmt = await withTimeout(conn.prepare(cypher), QUERY_TIMEOUT_MS, 'Prepare');
if (!stmt.isSuccess()) {
const errMsg = await stmt.getErrorMessage();
throw new Error(`Prepare failed: ${errMsg}`);
}
queryResult = await withTimeout(conn.execute(stmt, params), QUERY_TIMEOUT_MS, 'Execute');
const result = Array.isArray(queryResult) ? queryResult[0] : queryResult;
const rows = await result.getAll();
return rows;View on GitHub (pinned to d540b00184)
Solutions
- Run `gitnexus analyze` for the repository to create the index, then retry the query
- Verify the repoId matches exactly what was used during initialization — check for path/normalization differences
- If using `gitnexus serve`, ensure it's pointed at the correct repository storage directory
- For MCP, ensure the server has been configured with the correct repo path and that analyze completed successfully
Defensive patterns
Strategy: validation
Validate before calling
// Verify the pool is initialized for a repoId before querying
function isPoolInitialized(repoId: string): boolean {
return pool.has(repoId);
}
// Before calling executeParameterized:
if (!isPoolInitialized(repoId)) {
throw new Error(`Repo "${repoId}" not initialized — run gitnexus analyze first`);
} Try / catch
try {
const rows = await executeParameterized(repoId, cypher, params);
} catch (e) {
if (e instanceof Error && e.message.startsWith('LadybugDB not initialized')) {
// Prompt user to analyze, or initialize the pool
logger.error(`Repo "${repoId}" not indexed — run gitnexus analyze`);
}
throw e;
} Prevention
- Initialize the pool via initLbug before any query — serve/MCP should lazy-init on first query
- Verify repoId normalization (path casing, trailing slashes) matches between analyze and serve
- Handle LRU eviction gracefully by re-initializing evicted repos on demand
- Log pool state (initialized repoIds) at startup for debugging
When it happens
Trigger: Calling executeParameterized(repoId, cypher, params) for a repoId that hasn't been initialized via initLbug; calling it after the pool entry was evicted by LRU pressure from other repos; calling it after closeLbug was called on that repoId. Typical in MCP/serve contexts where the backend tries to query a repo that the user hasn't analyzed yet.
Common situations: MCP server or `gitnexus serve` receives a query for a repository that was never analyzed; the user switched repositories but the server wasn't reconfigured; an LRU eviction dropped the pool entry for a repo that hadn't been queried recently; the repoId doesn't match what was used during analyze (case sensitivity, path normalization).
Related errors
- LadybugDB not found at ${dbPath}. Run: gitnexus analyze
- Bridge query prepare failed: ${errMsg}
- Prepare failed: ${errMsg}
- LadybugDB WAL corruption detected for ${repoId}. Run `gitnex
- LadybugDB WAL corruption detected for ${repoId}. WAL corrupt
AI-assisted analysis of abhigyanpatwari/GitNexus@d540b00184 (2026-08-12).
Data as JSON: /api/errors/9f7128920a581e55.
Report an issue: GitHub.