googleapis/mcp-toolbox · error
unable to execute query: %w
Error message
unable to execute query: %w
What it means
RunSQL executes the statement through the pool with QueryContext (MindsDB supports MySQL prepared statements natively). Any driver- or server-level failure during execution is wrapped as "unable to execute query". This covers syntax errors, unknown tables/models, permission failures, and context cancellations.
Source
Thrown at internal/sources/mindsdb/mindsdb.go:114
}
func (s *Source) ToConfig() sources.SourceConfig {
return s.Config
}
func (s *Source) MindsDBPool() *sql.DB {
return s.Pool
}
func (s *Source) MySQLPool() *sql.DB {
return s.Pool
}
func (s *Source) RunSQL(ctx context.Context, statement string, params []any) (any, error) {
// MindsDB now supports MySQL prepared statements natively
results, err := s.MindsDBPool().QueryContext(ctx, statement, params...)
if err != nil {
return nil, fmt.Errorf("unable to execute query: %w", err)
}
cols, err := results.Columns()
if err != nil {
return nil, fmt.Errorf("unable to retrieve rows column name: %w", err)
}
// create an array of values for each column, which can be re-used to scan each row
rawValues := make([]any, len(cols))
values := make([]any, len(cols))
for i := range rawValues {
values[i] = &rawValues[i]
}
defer results.Close()
colTypes, err := results.ColumnTypes()
if err != nil {
return nil, fmt.Errorf("unable to get column types: %w", err)View on GitHub (pinned to 8cc6e09de2)
Solutions
- Check the wrapped driver error text for the underlying MySQL/MindsDB error code and message
- Validate the statement in a MindsDB SQL client before wiring it into the tool config
- Match the number of ? placeholders with the params slice length
- Increase query timeout if long-running MindsDB predictions hit the context deadline
Example fix
// before params: ["model_a"] statement: "SELECT * FROM mindsdb.??" # placeholder mismatch // after statement: "SELECT * FROM mindsdb.model_a" params: []
Defensive patterns
Strategy: try-catch
Validate before calling
var exists int err := pool.QueryRowContext(ctx, "SHOW TABLES IN mindsdb LIKE ?", modelName).Scan(&exists) _ = exists // validate model/table existence before running queries against it
Try / catch
results, err := pool.QueryContext(ctx, statement, params...)
if err != nil {
var mysqlErr *mysql.MySQLError
if errors.As(err, &mysqlErr) {
switch mysqlErr.Number {
case 1146: // unknown table/model
case 1064: // syntax error
}
}
if errors.Is(err, context.DeadlineExceeded) { /* raise timeout */ }
return err
} Prevention
- Test statements in the MindsDB SQL editor before adding them to tool configs
- Keep placeholder (?) count in sync with params length
- Set realistic query timeouts for long-running predictions
When it happens
Trigger: s.MindsDBPool().QueryContext(ctx, statement, params...) returns a non-nil error: SQL syntax error, unknown MindsDB model/table, parameter count mismatch, or ctx cancelled/timed out mid-query.
Common situations: Queries referencing a MindsDB model or database that doesn't exist; wrong number of ? placeholders vs params; long-running predictions hitting the query timeout; SQL that MySQL grammar rejects.
Related errors
- unable to execute query: %w
- unable to execute query: %w
- unable to execute query: %w
- unable to execute query: %w
- unable to create pool: %w
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/f1560e8bb868c5e0.
Report an issue: GitHub.