can1357/oh-my-pi · error · ToolError

SQLite table '${table}' not found

Error message

SQLite table '${table}' not found

What it means

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.

Source

Thrown at packages/coding-agent/src/tools/sqlite-reader.ts:325

		return 0;
	}

	const parsed = Number.parseInt(value, 10);
	if (!Number.isFinite(parsed) || parsed < 0) {
		throw new ToolError(`SQLite offset must be a non-negative integer; got '${value}'`);
	}
	return parsed;
}

function getTableMasterRow(db: Database, table: string): SqliteMasterRow {
	const row =
		db
			.prepare<SqliteMasterRow, [string]>(
				"SELECT name, sql FROM sqlite_master WHERE type = 'table' AND name NOT LIKE 'sqlite_%' AND name = ?",
			)
			.get(table) ?? null;
	if (!row) {
		throw new ToolError(`SQLite table '${table}' not found`);
	}
	return row;
}

function getTableInfoRows(db: Database, table: string): SqliteTableInfoRow[] {
	getTableMasterRow(db, table);
	return db.prepare<SqliteTableInfoRow, []>(`PRAGMA table_info(${quoteSqliteIdentifier(table)})`).all();
}

function getTableColumns(db: Database, table: string): string[] {
	return getTableInfoRows(db, table).map(column => column.name);
}

function getPrimaryKeyColumns(db: Database, table: string): SqliteTableInfoRow[] {
	return getTableInfoRows(db, table)
		.filter(column => column.pk > 0)
		.sort((left, right) => left.pk - right.pk);
}

View on GitHub (pinned to 9690622007)

Solutions

  1. Use the list selector (path without table subpath) or query sqlite_master yourself to see available table names, then retry with an exact name.
  2. Remove the 'sqlite_' prefix if targeting internal tables — they are deliberately inaccessible via this tool; query them with raw SQL tooling instead.
  3. Verify you opened the intended database file (check the path in the selector).
  4. Check for schema drift: run the app's migrations or inspect the current schema.

Example fix

// before
const sel = "app.sqlite?table=Users"; // table is actually 'users'
// after
const sel = "app.sqlite"; // list tables first, then
const sel2 = "app.sqlite?table=users";
Defensive patterns

Strategy: validation

Validate before calling

const tables = db.prepare<{ name: string }, []>("SELECT name FROM sqlite_master WHERE type='table' AND name NOT LIKE 'sqlite_%'").all();
if (!tables.some(t => t.name === table)) throw new Error(`table ${table} not in db`);

Try / catch

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; }

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31). Data as JSON: /api/errors/7190ae31bfec375f. Report an issue: GitHub.