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's QueryContext. Any error returned by the driver during query execution is wrapped as 'unable to execute query', preserving the original via %w.
Source
Thrown at internal/sources/clickhouse/clickhouse.go:115
return SourceType
}
func (s *Source) ToConfig() sources.SourceConfig {
return s.Config
}
func (s *Source) ClickHousePool() *sql.DB {
return s.Pool
}
func (s *Source) RunSQL(ctx context.Context, statement string, params parameters.ParamValues) (any, error) {
var sliceParams []any
if params != nil {
sliceParams = params.AsSlice()
}
results, err := s.ClickHousePool().QueryContext(ctx, statement, sliceParams...)
if err != nil {
return nil, fmt.Errorf("unable to execute query: %w", err)
}
defer results.Close()
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]
}
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
- Unwrap the error to see ClickHouse's server-side message.
- Test the statement directly in clickhouse-client.
- Verify table/column names and permissions for the configured user.
- Check the connection is still alive (server may have closed it).
Example fix
// before "SELECT * FORM my_table" // after "SELECT * FROM my_table"
Defensive patterns
Strategy: try-catch
Try / catch
rows, err := src.RunSQL(ctx, stmt)
if err != nil {
if strings.Contains(err.Error(), "unable to execute query") {
return fmt.Errorf("sql rejected: %w", err)
}
return err
} Prevention
- Test SQL in clickhouse-client before deployment.
- Verify user permissions on target tables.
- Keep statements syntactically valid for your server version.
When it happens
Trigger: Calling RunSQL with an invalid SQL statement, syntax error, missing table/column, insufficient permissions, or a connection dropped mid-query.
Common situations: Typos in SQL, referencing non-existent tables, ClickHouse rejecting the query syntax, auth failures, query size/limits exceeded.
Related errors
- unable to retrieve rows column name: %w
- unable to get column types: %w
- unable to parse rows: %w
- unable to create pool: %w
- unable to connect successfully: %w
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/2640745e02680dd1.
Report an issue: GitHub.