diegosouzapw/OmniRoute · error

[DB] Failed to verify proxy_logs schema:

Error message

[DB] Failed to verify proxy_logs schema:

What it means

The try around the proxy_logs schema verification (PRAGMA table_info(proxy_logs) plus conditional ALTER TABLE migrations such as adding egress_ip) threw, and the failure is only console.warn-ed so startup continues. Note the thrown/warned message ends with a colon — the underlying error text is not concatenated, so the actual SQLite cause (locked database, missing table, I/O error) is not surfaced by this message.

Solutions

  1. Reproduce the real cause: run `PRAGMA table_info(proxy_logs)` and the pending ALTER TABLE statements directly against the data directory's SQLite file
  2. If the database is locked, ensure no other OmniRoute process holds the file and rely on WAL journaling before retrying startup
  3. If proxy_logs does not exist yet, run the pending migrations so the table is created before column verification
  4. Treat the warning as non-fatal only if proxy_logs columns are already correct; otherwise fix the root cause, since missing columns silently break proxy-log writes
Defensive patterns

Strategy: try-catch

When it happens

Trigger: Thrown at src/lib/db/schemaColumns.ts:281 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of diegosouzapw/OmniRoute@a179ffed5b (2026-08-25). Data as JSON: /api/errors/bbc722b572aafc2d. Report an issue: GitHub.

Appendix: source

Thrown at src/lib/db/schemaColumns.ts:281

  } catch (error: unknown) {
    const message = error instanceof Error ? error.message : String(error);
    console.warn("[DB] Failed to verify call_logs schema:", message);
  }
}

export function ensureProxyLogsColumns(db: SqliteDatabase) {
  try {
    const columns = db.prepare("PRAGMA table_info(proxy_logs)").all() as Array<{
      name?: string;
    }>;
    const columnNames = new Set(columns.map((column) => String(column.name ?? "")));
    if (!columnNames.has("egress_ip")) {
      db.exec("ALTER TABLE proxy_logs ADD COLUMN egress_ip TEXT");
      console.log("[DB] Added proxy_logs.egress_ip column");
    }
  } catch (error: unknown) {
    const message = error instanceof Error ? error.message : String(error);
    console.warn("[DB] Failed to verify proxy_logs schema:", message);
  }
}

export function hasColumn(db: SqliteDatabase, tableName: string, columnName: string): boolean {
  const rows = db.prepare(`PRAGMA table_info(${tableName})`).all() as Array<{ name?: string }>;
  return rows.some((row) => row.name === columnName);
}

export function hasTable(db: SqliteDatabase, tableName: string): boolean {
  return Boolean(
    db.prepare("SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?").get(tableName)
  );
}

export function quoteIdentifier(identifier: string): string {
  return `"${identifier.replace(/"/g, '""')}"`;
}

View on GitHub (pinned to a179ffed5b)