abhigyanpatwari/GitNexus · warning

Could not read the LadybugDB index catalog (CALL SHOW_INDEXE

Error message

Could not read the LadybugDB index catalog (CALL SHOW_INDEXES()); extension-gated DML checks must assume an index may be present.

What it means

readIndexCatalogRows() could not execute `CALL SHOW_INDEXES() RETURN *` (missing extension in the LadybugDB build, connection fault). It returns undefined instead of rows, and the surrounding IndexCatalogSnapshot model distinguishes 'could not prove anything' from 'proved no index': extension-gated DML checks must then assume an index may be present (conservative).

Source

Thrown at gitnexus/src/core/lbug/lbug-adapter.ts:3517

 *
 * `undefined` means "could not prove anything" and every caller must treat it
 * as fail-closed (assume an index may be present), never as "no indexes". All
 * three readers below honour that, `ftsIndexExistsInCatalog` included since
 * #2841 review H3. To hand ONE read to several gates, use
 * {@link readIndexCatalogSnapshot} — passing this `undefined` on cannot be
 * distinguished from passing nothing at all.
 */
export const readIndexCatalogRows = async (): Promise<IndexCatalogRow[] | undefined> => {
  const targetConn = conn;
  if (!targetConn) {
    throw new Error('LadybugDB not initialized. Call initLbug first.');
  }
  try {
    return (await withConnLock(async () =>
      readQueryRows(await targetConn.query('CALL SHOW_INDEXES() RETURN *')),
    )) as IndexCatalogRow[];
  } catch (err) {
    logger.warn(
      { err },
      'Could not read the LadybugDB index catalog (CALL SHOW_INDEXES()); ' +
        'extension-gated DML checks must assume an index may be present.',
    );
    return undefined;
  }
};

/**
 * The failed half of an {@link IndexCatalogSnapshot}: the caller DID read the
 * catalog and could not prove anything.
 *
 * It exists because `undefined` was overloaded (#2841 review §5.A). The gates
 * below took `indexRows?: IndexCatalogRow[]`, so "my read failed" and "I passed
 * you nothing" were the SAME value, and each gate's `?? (await
 * readIndexCatalogRows())` silently re-read the catalog — turning the one shared
 * read the call site documents into three round-trips and three identical
 * warnings on the failure path, with the two gates free to decide from DIFFERENT

View on GitHub (pinned to 0d1aed942f)

Solutions

  1. Update gitnexus (npm install gitnexus@latest) so the vendored LadybugDB supports SHOW_INDEXES.
  2. Handle the undefined return conservatively — do not treat it as 'no indexes' when deciding on extension-gated DML.
  3. Re-run the operation; transient connection faults resolve on retry.
  4. Check the logged err for the exact engine message if it persists.

Example fix

// before: assuming rows means no index
const rows = await readIndexCatalogRows();
if (rows.length === 0) skipIndexAwarePath();

// after: undefined means unknown — stay conservative
const rows = await readIndexCatalogRows();
if (rows === undefined) assumeIndexMayExist();
else if (rows.length === 0) skipIndexAwarePath();
Defensive patterns

Strategy: type-guard

Type guard

type Catalog = IndexCatalogRow[] | undefined; // undefined === 'unknown', NOT 'no indexes'
function catalogProves(rows: Catalog): rows is IndexCatalogRow[] {
  return Array.isArray(rows);
}

Try / catch

const rows = await readIndexCatalogRows(); // never throws; returns undefined on failure
if (!catalogProves(rows)) {
  takeConservativePath(); // assume an index may be present
} else {
  decideFrom(rows);
}

Prevention

When it happens

Trigger: Any code path calling readIndexCatalogRows() — index-aware DELETE optimization decisions — where the SHOW_INDEXES catalog call throws: older LadybugDB without the extension, a broken connection, or a read-only/busy catalog moment. The function requires initLbug first and throws separately if conn is unset.

Common situations: LadybugDB version drift after upgrading the package but not the vendored native build; exotic builds where catalog extensions are compiled out; concurrent access corner cases during startup.

Related errors


AI-assisted analysis of abhigyanpatwari/GitNexus@0d1aed942f (2026-08-20). Data as JSON: /api/errors/def98ee34fc70467. Report an issue: GitHub.