{"record":{"id":"2bc19fd34d12ad2b","repo":"can1357/oh-my-pi","slug":"sqlite-row-lookups-cannot-be-combined-with-query-p","errorCode":null,"errorMessage":"SQLite row lookups cannot be combined with query parameters","messagePattern":"SQLite row lookups cannot be combined with query parameters","errorType":"validation","errorClass":"ToolError","httpStatus":null,"severity":"error","filePath":"packages/coding-agent/src/tools/sqlite-reader.ts","lineNumber":593,"sourceCode":"\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) {\n\t\tthrow new ToolError(\"SQLite selectors must include a table name\");\n\t}\n\n\tif (key !== undefined && key.length > 0) {\n\t\tif (params.size > 0) {\n\t\t\tthrow new ToolError(\"SQLite row lookups cannot be combined with query parameters\");\n\t\t}\n\t\treturn { kind: \"row\", table, key };\n\t}\n\n\tconst where = validateWhereClause(params.get(\"where\") ?? undefined);\n\tconst order = params.get(\"order\")?.trim() || undefined;\n\tconst hasQueryParams = params.has(\"limit\") || params.has(\"offset\") || order !== undefined || where !== undefined;\n\tif (hasQueryParams) {\n\t\tconst knownKeys = new Set([\"limit\", \"offset\", \"order\", \"where\"]);\n\t\tfor (const keyName of params.keys()) {\n\t\t\tif (!knownKeys.has(keyName)) {\n\t\t\t\tthrow new ToolError(`Unsupported SQLite query parameter '${keyName}'`);\n\t\t\t}\n\t\t}\n\t\treturn {\n\t\t\tkind: \"query\",\n\t\t\ttable,\n\t\t\tlimit: parseLimit(params.get(\"limit\"), DEFAULT_QUERY_LIMIT),","sourceCodeStart":575,"sourceCodeEnd":611,"githubUrl":"https://github.com/can1357/oh-my-pi/blob/969062200754ea02cfac922e5ebb8c608c079e15/packages/coding-agent/src/tools/sqlite-reader.ts#L575-L611","documentation":"Thrown when a row lookup selector (table:key form with a non-empty key) is combined with query parameters. Row lookup is an exact-key fetch and accepts no where/limit/order params, so their presence is rejected as ambiguous.","triggerScenarios":"'db.sqlite/users:42?limit=1'; adding where/order to a keyed lookup; generic URL builders that always append params.","commonSituations":"Reusing a param-appending helper for both list and row-fetch URLs; leftover params after switching from a table query to a keyed lookup.","solutions":["Remove all query params when doing a keyed row lookup","If you need filtering/pagination, use the table selector without a key instead","Fetch the row by key and filter client-side if needed"],"exampleFix":"// before\ndb.sqlite/users:42?where=active=1\n// after\ndb.sqlite/users:42","handlingStrategy":"validation","validationCode":"if (key != null && key.length > 0 && Object.keys(params).length > 0) {\n  throw new Error('row lookups (table:key) take no query params');\n}","typeGuard":null,"tryCatchPattern":"try {\n  await reader.read(`db.sqlite/${table}:${key}`);\n} catch (err) {\n  if (err instanceof ToolError && err.message.includes('row lookups cannot be combined')) {\n    // strip params or switch to the table-query form without :key\n  } else throw err;\n}","preventionTips":["Use separate helpers for row-fetch (no params) and table-query (params allowed)","Strip accumulated params when switching from list mode to keyed lookup","Encode the key safely but never attach where/limit/order to keyed URLs"],"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"}