can1357/oh-my-pi · error · ToolError

SQLite selectors must include a table name

Error message

SQLite selectors must include a table name

What it means

Thrown when the table selector resolves to an empty table name — typically a sub-path like 'db.sqlite/:key' or ':123' where nothing precedes the ':' separator. The parser requires a table name before the colon.

Source

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

		}
		if (!rawQuery.trim()) {
			throw new ToolError("SQLite query parameter 'q' cannot be empty");
		}
		return { kind: "raw", sql: rawQuery };
	}

	if (!normalizedSubPath) {
		if (params.size > 0) {
			throw new ToolError("SQLite query parameters require a table selector or q=SELECT...");
		}
		return { kind: "list" };
	}

	const separatorIndex = normalizedSubPath.indexOf(":");
	const table = separatorIndex === -1 ? normalizedSubPath : normalizedSubPath.slice(0, separatorIndex);
	const key = separatorIndex === -1 ? undefined : normalizedSubPath.slice(separatorIndex + 1);
	if (!table) {
		throw new ToolError("SQLite selectors must include a table name");
	}

	if (key !== undefined && key.length > 0) {
		if (params.size > 0) {
			throw new ToolError("SQLite row lookups cannot be combined with query parameters");
		}
		return { kind: "row", table, key };
	}

	const where = validateWhereClause(params.get("where") ?? undefined);
	const order = params.get("order")?.trim() || undefined;
	const hasQueryParams = params.has("limit") || params.has("offset") || order !== undefined || where !== undefined;
	if (hasQueryParams) {
		const knownKeys = new Set(["limit", "offset", "order", "where"]);
		for (const keyName of params.keys()) {
			if (!knownKeys.has(keyName)) {
				throw new ToolError(`Unsupported SQLite query parameter '${keyName}'`);
			}

View on GitHub (pinned to 9690622007)

Solutions

  1. Include the table name before the colon: 'users:42'
  2. Fix the empty/unset table variable in the URL builder
  3. If you meant a row lookup, format is table:key, not :key

Example fix

// before
db.sqlite/:42
// after
db.sqlite/users:42
Defensive patterns

Strategy: validation

Validate before calling

const m = subPath.match(/^([^:]+)(?::(.*))?$/);
if (!m || !m[1]) throw new Error('selector must be table or table:key');

Try / catch

try {
  await reader.read(`db.sqlite/${subPath}`);
} catch (err) {
  if (err instanceof ToolError && err.message.includes('must include a table name')) {
    // fix the selector format — table name must precede ':'
  } else throw err;
}

Prevention

When it happens

Trigger: Sub-path ':id' or '/:rowid' where the table was omitted; empty table variable interpolated into the path; malformed selector with a leading colon.

Common situations: Template strings with an unset table variable; confusing the tool's 'table:key' syntax with ':param' route syntax from web frameworks.

Understand the failure class

Background: Missing required parameter errors: what 'X is required' and 'the required X param is missing' mean, and how to fix them — this error's family across 27 libraries.

Related errors


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