can1357/oh-my-pi · error · ToolError
SQLite raw queries cannot be combined with table selectors o
Error message
SQLite raw queries cannot be combined with table selectors or pagination
What it means
Thrown by the selector/query-string parser when a raw SQL query parameter 'q' is combined with a table sub-path or any other query parameters. Raw queries and the structured table/pagination API are mutually exclusive modes, so the parser rejects any mix.
Source
Thrown at packages/coding-agent/src/tools/sqlite-reader.ts:569
}
export async function isSqliteFile(absolutePath: string): Promise<boolean> {
try {
return looksLikeSqlite(await Bun.file(absolutePath).slice(0, SQLITE_MAGIC.byteLength).bytes());
} catch {
return false;
}
}
export function parseSqliteSelector(subPath: string, queryString: string): SqliteSelector {
const normalizedSubPath = subPath.replace(/^:+/, "").trim();
const params = new URLSearchParams(queryString);
const rawQuery = params.get("q");
if (rawQuery !== null) {
const otherKeys = [...params.keys()].filter(key => key !== "q");
if (normalizedSubPath || otherKeys.length > 0) {
throw new ToolError("SQLite raw queries cannot be combined with table selectors or pagination");
}
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) {View on GitHub (pinned to 9690622007)
Solutions
- Use q alone with no other params and no table sub-path
- Move pagination into the SQL itself (LIMIT/OFFSET in the raw query)
- Drop the q param and use the table selector API if you want limit/offset/where/order params
Example fix
// before db.sqlite?q=SELECT * FROM users&limit=10 // after db.sqlite?q=SELECT * FROM users LIMIT 10
Defensive patterns
Strategy: validation
Validate before calling
if (rawSql != null && (tableSubPath || otherParams.length > 0)) {
throw new Error('q must be used alone: no table path or extra params');
} Try / catch
try {
await reader.read(url);
} catch (err) {
if (err instanceof ToolError && err.message.includes('cannot be combined with')) {
// rebuild the URL in one mode: raw q OR table+params
} else throw err;
} Prevention
- Build raw-query URLs from a dedicated helper that only emits q
- Put LIMIT/OFFSET inside the raw SQL, not as URL params
- Audit URL builders that merge params from multiple sources
When it happens
Trigger: URLs like 'db.sqlite?q=SELECT 1&limit=10'; 'db.sqlite/users?q=SELECT * FROM users'; adding where/order params alongside q=...
Common situations: Appending pagination params to a raw query out of habit from the table API; building URLs programmatically where a table prefix and q param both get set; template that always emits limit/offset.
Related errors
- SQLite query parameters require a table selector or q=SELECT
- SQLite row lookups cannot be combined with query parameters
- vault://${op} requires '${name}' query parameter
- SQLite query parameter 'q' cannot be empty
- SQLite selectors must include a table name
AI-assisted analysis of can1357/oh-my-pi@9690622007 (2026-08-31).
Data as JSON: /api/errors/f16cd4a85bcc19e0.
Report an issue: GitHub.