{"record":{"id":"f16cd4a85bcc19e0","repo":"can1357/oh-my-pi","slug":"sqlite-raw-queries-cannot-be-combined-with-table-s","errorCode":null,"errorMessage":"SQLite raw queries cannot be combined with table selectors or pagination","messagePattern":"SQLite raw queries cannot be combined with table selectors or pagination","errorType":"validation","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tools/sqlite-reader.ts","lineNumber":569,"sourceCode":"}\n\nexport async function isSqliteFile(absolutePath: string): Promise<boolean> {\n\ttry {\n\t\treturn looksLikeSqlite(await Bun.file(absolutePath).slice(0, SQLITE_MAGIC.byteLength).bytes());\n\t} catch {\n\t\treturn false;\n\t}\n}\n\nexport function parseSqliteSelector(subPath: string, queryString: string): SqliteSelector {\n\tconst normalizedSubPath = subPath.replace(/^:+/, \"\").trim();\n\tconst params = new URLSearchParams(queryString);\n\tconst rawQuery = params.get(\"q\");\n\n\tif (rawQuery !== null) {\n\t\tconst otherKeys = [...params.keys()].filter(key => key !== \"q\");\n\t\tif (normalizedSubPath || otherKeys.length > 0) {\n\t\t\tthrow new ToolError(\"SQLite raw queries cannot be combined with table selectors or pagination\");\n\t\t}\n\t\tif (!rawQuery.trim()) {\n\t\t\tthrow new ToolError(\"SQLite query parameter 'q' cannot be empty\");\n\t\t}\n\t\treturn { kind: \"raw\", sql: rawQuery };\n\t}\n\n\tif (!normalizedSubPath) {\n\t\tif (params.size > 0) {\n\t\t\tthrow new ToolError(\"SQLite query parameters require a table selector or q=SELECT...\");\n\t\t}\n\t\treturn { kind: \"list\" };\n\t}\n\n\tconst separatorIndex = normalizedSubPath.indexOf(\":\");\n\tconst table = separatorIndex === -1 ? normalizedSubPath : normalizedSubPath.slice(0, separatorIndex);\n\tconst key = separatorIndex === -1 ? undefined : normalizedSubPath.slice(separatorIndex + 1);\n\tif (!table) {","sourceCodeStart":551,"sourceCodeEnd":587,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tools/sqlite-reader.ts#L551-L587","documentation":"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.","triggerScenarios":"URLs like 'db.sqlite?q=SELECT 1&limit=10'; 'db.sqlite/users?q=SELECT * FROM users'; adding where/order params alongside q=...","commonSituations":"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.","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"],"exampleFix":"// before\ndb.sqlite?q=SELECT * FROM users&limit=10\n// after\ndb.sqlite?q=SELECT * FROM users LIMIT 10","handlingStrategy":"validation","validationCode":"if (rawSql != null && (tableSubPath || otherParams.length > 0)) {\n  throw new Error('q must be used alone: no table path or extra params');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await reader.read(url);\n} catch (err) {\n  if (err instanceof ToolError && err.message.includes('cannot be combined with')) {\n    // rebuild the URL in one mode: raw q OR table+params\n  } else throw err;\n}","preventionTips":["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"],"tags":["sqlite","validation","api-misuse","query-parameters"],"backgroundTag":"incompatible-parameter-combination","analyzedSha":"969062200754ea02cfac922e5ebb8c608c079e15","analyzedAt":"2026-08-31T10:29:35.737Z","schemaVersion":2},"datasetVersion":"2026-08-31T14:17:45.589Z"}