{"record":{"id":"cf75009373445bd2","repo":"googleapis/mcp-toolbox","slug":"unable-to-execute-query-w-cf7500","errorCode":null,"errorMessage":"unable to execute query: %w","messagePattern":"unable to execute query: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/sqlite/sqlite.go","lineNumber":108,"sourceCode":"\nfunc (s *Source) SourceType() string {\n\treturn SourceType\n}\n\nfunc (s *Source) ToConfig() sources.SourceConfig {\n\treturn s.Config\n}\n\nfunc (s *Source) SQLiteDB() *sql.DB {\n\treturn s.Db\n}\n\nfunc (s *Source) RunSQL(ctx context.Context, statement string, params []any) (any, error) {\n\t// Execute the SQL query with parameters\n\tstatement = sqlcommenter.PrependComment(ctx, statement, SourceType, s.SQLCommenter)\n\trows, err := s.SQLiteDB().QueryContext(ctx, statement, params...)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to execute query: %w\", err)\n\t}\n\tdefer rows.Close()\n\n\t// Get column names\n\tcols, err := rows.Columns()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to get column names: %w\", err)\n\t}\n\n\t// The sqlite driver does not support ColumnTypes, so we can't get the\n\t// underlying database type of the columns. We'll have to rely on the\n\t// generic `any` type and then handle the JSON data separately.\n\trawValues := make([]any, len(cols))\n\tvalues := make([]any, len(cols))\n\tfor i := range rawValues {\n\t\tvalues[i] = &rawValues[i]\n\t}\n","sourceCodeStart":90,"sourceCodeEnd":126,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/sqlite/sqlite.go#L90-L126","documentation":"sqlite RunSQL (internal/sources/sqlite/sqlite.go:108) executes the caller's statement via QueryContext after prepending an sqlcommenter comment. Any driver-level failure during query execution is wrapped as \"unable to execute query\". This covers SQL syntax errors, missing tables/columns, and lock contention.","triggerScenarios":"RunSQL called with a statement the SQLite driver fails to run: syntax error, referencing a nonexistent table/column, database locked, datatype mismatch, or a bound parameter count mismatch.","commonSituations":"Tool config SQL with a typo or referencing a table that doesn't exist; concurrent writers causing 'database is locked'; passing the wrong number of parameters; sqlite database replaced/migrated without the expected schema.","solutions":["Read the wrapped driver error for the specific SQLite result code (e.g. SQLITE_LOCKED, SQLITE_ERROR)","Test the exact statement with the sqlite3 CLI to reproduce and fix syntax/schema issues","If 'database is locked', reduce concurrent writers or enable WAL mode: PRAGMA journal_mode=WAL;","Verify the parameterized query's placeholder count matches the params slice length"],"exampleFix":"// before\nPRAGMA journal_mode=DELETE;\n// after\nPRAGMA journal_mode=WAL; -- reduces writer lock contention","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"res, err := source.RunSQL(ctx, stmt, params)\nif err != nil {\n\tvar se *sqlite.Error\n\tif errors.As(err, &se) && strings.Contains(err.Error(), \"locked\") {\n\t\t// back off and retry, or switch to WAL mode\n\t}\n\treturn fmt.Errorf(\"sqlite query failed: %w\", err)\n}","preventionTips":["Validate tool SQL against the schema in tests before deploy","Enable WAL mode to reduce lock errors","Keep placeholder/param counts consistent","Test statements with the sqlite3 CLI using the same file"],"tags":["sqlite","sql-execution","query"],"backgroundTag":"database-query-failed","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}