can1357/oh-my-pi · error · ToolError

SQLite table '${table}' has no column named '${column}'

Error message

SQLite table '${table}' has no column named '${column}'

What it means

Thrown by validateWriteColumns when the data object contains a key that is not a column of the target table. Every write key is checked against getTableColumns(db, table) before any binding is built, protecting against silently failed or SQL-erroring writes.

Source

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

		typeof value === "string" ||
		typeof value === "number" ||
		typeof value === "boolean" ||
		typeof value === "bigint"
	) {
		return value;
	}
	throw new ToolError(`SQLite column '${column}' only accepts JSON scalar values or null`);
}

function validateWriteColumns(
	db: Database,
	table: string,
	data: Record<string, unknown>,
): Array<[string, SqliteBinding]> {
	const columns = new Set(getTableColumns(db, table));
	return Object.entries(data).map(([column, value]) => {
		if (!columns.has(column)) {
			throw new ToolError(`SQLite table '${table}' has no column named '${column}'`);
		}
		return [column, normalizeWriteValue(value, column)];
	});
}

export function parseSqlitePathCandidates(filePath: string): SqlitePathCandidate[] {
	const normalized = filePath.replace(/\\/g, "/");
	const seen = new Set<string>();
	const candidates: SqlitePathCandidate[] = [];

	let match: RegExpExecArray | null;
	while (true) {
		match = SQLITE_PATH_PATTERN.exec(normalized);
		if (match === null) {
			break;
		}

		const end = match.index + match[0].length;

View on GitHub (pinned to 9690622007)

Solutions

  1. Inspect the table schema and align data keys to actual column names
  2. Fix typos in the data object keys
  3. Remove fields that don't exist in the table or map them to existing columns
  4. After migrations, update the write payload to the new column names

Example fix

// before
write('users', { usernane: 'bob' })
// after
write('users', { username: 'bob' })
Defensive patterns

Strategy: validation

Validate before calling

const cols = new Set(await listTableColumns(table));
const bad = Object.keys(data).filter(k => !cols.has(k));
if (bad.length) throw new Error(`unknown columns for '${table}': ${bad.join(', ')}`);

Try / catch

try {
  await writer.write('users', data);
} catch (err) {
  if (err instanceof ToolError && err.message.includes('has no column named')) {
    // refresh schema, drop unknown keys, and retry
  } else throw err;
}

Prevention

When it happens

Trigger: write('users', { usernane: 'x' }) — typo; writing fields removed/renamed by a recent migration; including extra payload fields (e.g. id in an insert where the column doesn't exist); writing to the wrong table.

Common situations: Schema drift after migrations; API payloads passed straight through to the writer; case mismatches between payload keys and actual column names.

Related errors


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