{"record":{"id":"7190ae31bfec375f","repo":"can1357/oh-my-pi","slug":"sqlite-table-table-not-found","errorCode":null,"errorMessage":"SQLite table '${table}' not found","messagePattern":"SQLite table '(.+?)' not found","errorType":"exception","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tools/sqlite-reader.ts","lineNumber":325,"sourceCode":"\t\treturn 0;\n\t}\n\n\tconst parsed = Number.parseInt(value, 10);\n\tif (!Number.isFinite(parsed) || parsed < 0) {\n\t\tthrow new ToolError(`SQLite offset must be a non-negative integer; got '${value}'`);\n\t}\n\treturn parsed;\n}\n\nfunction getTableMasterRow(db: Database, table: string): SqliteMasterRow {\n\tconst row =\n\t\tdb\n\t\t\t.prepare<SqliteMasterRow, [string]>(\n\t\t\t\t\"SELECT name, sql FROM sqlite_master WHERE type = 'table' AND name NOT LIKE 'sqlite_%' AND name = ?\",\n\t\t\t)\n\t\t\t.get(table) ?? null;\n\tif (!row) {\n\t\tthrow new ToolError(`SQLite table '${table}' not found`);\n\t}\n\treturn row;\n}\n\nfunction getTableInfoRows(db: Database, table: string): SqliteTableInfoRow[] {\n\tgetTableMasterRow(db, table);\n\treturn db.prepare<SqliteTableInfoRow, []>(`PRAGMA table_info(${quoteSqliteIdentifier(table)})`).all();\n}\n\nfunction getTableColumns(db: Database, table: string): string[] {\n\treturn getTableInfoRows(db, table).map(column => column.name);\n}\n\nfunction getPrimaryKeyColumns(db: Database, table: string): SqliteTableInfoRow[] {\n\treturn getTableInfoRows(db, table)\n\t\t.filter(column => column.pk > 0)\n\t\t.sort((left, right) => left.pk - right.pk);\n}","sourceCodeStart":307,"sourceCodeEnd":343,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tools/sqlite-reader.ts#L307-L343","documentation":"getTableMasterRow looks up the requested table in sqlite_master (excluding internal sqlite_% tables) before any schema introspection or row access. If no user table with that exact name exists, it throws this ToolError. It guards getTableInfoRows, row lookup, getRowByKey/getRowByRowId, insertRow, and updateRowByKey.","triggerScenarios":"Any selector targeting a table name that does not exist in the database: typo, wrong case on a case-sensitive lookup (SQLite identifiers are case-insensitive for ASCII but the exact-name match still needs to resolve), targeting an internal sqlite_sequence-style table (excluded by the NOT LIKE 'sqlite_%' filter), or querying the wrong database file.","commonSituations":"Assuming a table exists from an outdated schema dump; trying to read internal SQLite tables (sqlite_master, sqlite_sequence) via the tool; opening the wrong .sqlite file in the project; schema migrations renamed/dropped the table.","solutions":["Use the list selector (path without table subpath) or query sqlite_master yourself to see available table names, then retry with an exact name.","Remove the 'sqlite_' prefix if targeting internal tables — they are deliberately inaccessible via this tool; query them with raw SQL tooling instead.","Verify you opened the intended database file (check the path in the selector).","Check for schema drift: run the app's migrations or inspect the current schema."],"exampleFix":"// before\nconst sel = \"app.sqlite?table=Users\"; // table is actually 'users'\n// after\nconst sel = \"app.sqlite\"; // list tables first, then\nconst sel2 = \"app.sqlite?table=users\";","handlingStrategy":"validation","validationCode":"const tables = db.prepare<{ name: string }, []>(\"SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%'\").all();\nif (!tables.some(t => t.name === table)) throw new Error(`table ${table} not in db`);","typeGuard":null,"tryCatchPattern":"try { return await readSelector(`${dbPath}?table=${table}`); } catch (e) { if (e instanceof ToolError && e.message.includes(\"not found\")) { const list = await readSelector(dbPath); /* show available tables */ } throw e; }","preventionTips":["List tables first when the schema is unknown.","Use exact table names from sqlite_master; internal sqlite_% tables are blocked.","Confirm the selector points at the intended database file."],"tags":["sqlite","identifier","database"],"backgroundTag":"table-not-found","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}