{"record":{"id":"578088546402b3ce","repo":"googleapis/mcp-toolbox","slug":"unable-to-execute-query-w-578088","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/firebird/firebird.go","lineNumber":107,"sourceCode":"\treturn false\n}\n\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) FirebirdDB() *sql.DB {\n\treturn s.Db\n}\n\nfunc (s *Source) RunSQL(ctx context.Context, statement string, params []any) (any, error) {\n\trows, err := s.FirebirdDB().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\tcols, err := rows.Columns()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to get columns: %w\", err)\n\t}\n\n\tvalues := make([]any, len(cols))\n\tscanArgs := make([]any, len(values))\n\tfor i := range values {\n\t\tscanArgs[i] = &values[i]\n\t}\n\n\tout := []any{}\n\tfor rows.Next() {\n\n\t\terr = rows.Scan(scanArgs...)","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/firebird/firebird.go#L89-L125","documentation":"Wraps the database/sql error returned by QueryContext when executing a statement against the Firebird pool in RunSQL. This includes Firebird SQL syntax errors, permission failures, and driver-level connection errors at query time.","triggerScenarios":"RunSQL called with a statement that is invalid Firebird SQL, references a missing table/column, uses unsupported parameter placeholders, or the pooled connection has been dropped (server restart, ConnMaxLifetime expiry race).","commonSituations":"MySQL/Postgres-style syntax (LIMIT, double quotes) used against Firebird dialect; missing table in the configured database; user lacking SELECT grants; stale connections after server restart; passing named parameters where positional ? expected.","solutions":["Run the statement in isql with the same user to get the native Firebird error (ISC code)","Check Firebird dialect compatibility of the SQL syntax (e.g. use FIRST n SKIP m instead of LIMIT)","Verify the table/column exists and the user has SELECT privilege","Test parameters count/placeholders match the statement"],"exampleFix":"// before\nrows, err := s.FirebirdDB().QueryContext(ctx, statement, params...)\nif err != nil {\n    return nil, fmt.Errorf(\"unable to execute query: %w\", err)\n}\n// after\nrows, err := s.FirebirdDB().QueryContext(ctx, statement, params...)\nif err != nil {\n    var fbErr *retriableError\n    if errors.As(err, &fbErr) {\n        return nil, fmt.Errorf(\"unable to execute query (transient): %w\", err)\n    }\n    return nil, fmt.Errorf(\"unable to execute query: %w\", err)\n}","handlingStrategy":"try-catch","validationCode":"// Validate statement is non-empty before invoking\nif strings.TrimSpace(statement) == \"\" { return errors.New(\"empty SQL statement\") }","typeGuard":"func isFirebirdSyntaxErr(err error) bool {\n    return strings.Contains(err.Error(), \"Dynamic SQL Error\") || strings.Contains(err.Error(), \"Token unknown\")\n}","tryCatchPattern":"rows, err := s.FirebirdDB().QueryContext(ctx, statement, params...)\nif err != nil {\n    if isFirebirdSyntaxErr(err) {\n        return nil, fmt.Errorf(\"invalid Firebird SQL: %w\", err)\n    }\n    if ctx.Err() != nil {\n        return nil, fmt.Errorf(\"query cancelled: %w\", ctx.Err())\n    }\n    return nil, fmt.Errorf(\"unable to execute query: %w\", err)\n}","preventionTips":["Test all statements against a real Firebird instance in CI (dialect differences bite often)","Use ExecContext for DML/DDL without RETURNING instead of QueryContext","Match placeholder style and parameter count to the statement","Monitor connection lifetime settings after server restarts"],"tags":["firebird","sql","query-execution"],"backgroundTag":"query-execution-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"}