{"record":{"id":"bbc722b572aafc2d","repo":"diegosouzapw/OmniRoute","slug":"db-failed-to-verify-proxy-logs-schema","errorCode":null,"errorMessage":"[DB] Failed to verify proxy_logs schema:","messagePattern":"\\[DB\\] Failed to verify proxy_logs schema:","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/lib/db/schemaColumns.ts","lineNumber":281,"sourceCode":"  } catch (error: unknown) {\n    const message = error instanceof Error ? error.message : String(error);\n    console.warn(\"[DB] Failed to verify call_logs schema:\", message);\n  }\n}\n\nexport function ensureProxyLogsColumns(db: SqliteDatabase) {\n  try {\n    const columns = db.prepare(\"PRAGMA table_info(proxy_logs)\").all() as Array<{\n      name?: string;\n    }>;\n    const columnNames = new Set(columns.map((column) => String(column.name ?? \"\")));\n    if (!columnNames.has(\"egress_ip\")) {\n      db.exec(\"ALTER TABLE proxy_logs ADD COLUMN egress_ip TEXT\");\n      console.log(\"[DB] Added proxy_logs.egress_ip column\");\n    }\n  } catch (error: unknown) {\n    const message = error instanceof Error ? error.message : String(error);\n    console.warn(\"[DB] Failed to verify proxy_logs schema:\", message);\n  }\n}\n\nexport function hasColumn(db: SqliteDatabase, tableName: string, columnName: string): boolean {\n  const rows = db.prepare(`PRAGMA table_info(${tableName})`).all() as Array<{ name?: string }>;\n  return rows.some((row) => row.name === columnName);\n}\n\nexport function hasTable(db: SqliteDatabase, tableName: string): boolean {\n  return Boolean(\n    db.prepare(\"SELECT 1 FROM sqlite_master WHERE type = 'table' AND name = ?\").get(tableName)\n  );\n}\n\nexport function quoteIdentifier(identifier: string): string {\n  return `\"${identifier.replace(/\"/g, '\"\"')}\"`;\n}\n","sourceCodeStart":263,"sourceCodeEnd":299,"githubUrl":"https://github.com/diegosouzapw/OmniRoute/blob/a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d/src/lib/db/schemaColumns.ts#L263-L299","documentation":"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.","triggerScenarios":"Thrown at src/lib/db/schemaColumns.ts:281 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reproduce the real cause: run `PRAGMA table_info(proxy_logs)` and the pending ALTER TABLE statements directly against the data directory's SQLite file","If the database is locked, ensure no other OmniRoute process holds the file and rely on WAL journaling before retrying startup","If proxy_logs does not exist yet, run the pending migrations so the table is created before column verification","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"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"a179ffed5bb2e0b883b9ae7214ce8717b2a94c4d","analyzedAt":"2026-08-25T18:35:09.898Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}