googleapis/mcp-toolbox · error
errors encountered when converting values: %w
Error message
errors encountered when converting values: %w
What it means
After scanning, RunSQL converts each raw driver value to a Go type via mysqlcommon.ConvertToType using the column's type; if that conversion fails for any column, the whole RunSQL call fails with this wrapped error.
Source
Thrown at internal/sources/oceanbase/oceanbase.go:147
out := []any{}
for results.Next() {
err := results.Scan(values...)
if err != nil {
return nil, fmt.Errorf("unable to parse row: %w", err)
}
vMap := make(map[string]any)
for i, name := range cols {
val := rawValues[i]
if val == nil {
vMap[name] = nil
continue
}
// oceanbase uses mysql driver
vMap[name], err = mysqlcommon.ConvertToType(colTypes[i], val)
if err != nil {
return nil, fmt.Errorf("errors encountered when converting values: %w", err)
}
}
out = append(out, vMap)
}
if err := results.Err(); err != nil {
return nil, fmt.Errorf("errors encountered during row iteration: %w", err)
}
return out, nil
}
func initOceanBaseConnectionPool(ctx context.Context, tracer trace.Tracer, name, host, port, user, pass, dbname, queryTimeout string) (*sql.DB, error) {
_, span := sources.InitConnectionSpan(ctx, tracer, SourceType, name)
defer span.End()
dsn := fmt.Sprintf("%s:%s@tcp(%s:%s)/%s?parseTime=true", user, pass, host, port, dbname)
View on GitHub (pinned to 8cc6e09de2)
Solutions
- Inspect the wrapped conversion error to find the offending column and type
- Cast the problematic column in SQL to a well-supported type (CHAR, DECIMAL, DATETIME)
- Pin/upgrade the mysql driver so type codes match what ConvertToType expects
- Handle the column manually by selecting it as a string
Example fix
// before SELECT created_ts FROM events; // after SELECT DATE_FORMAT(created_ts, '%Y-%m-%d %H:%i:%s') AS created_ts FROM events;
Defensive patterns
Strategy: validation
Validate before calling
// ensure only converter-friendly types are selected
for _, col := range []string{"bit_col", "geom"} {
if strings.Contains(sql, col) {
sql = strings.Replace(sql, col, "CAST("+col+" AS CHAR)", 1)
}
} Try / catch
out, err := src.RunSQL(ctx, sql)
if err != nil && strings.Contains(err.Error(), "converting values") {
// retry with string-cast columns
} Prevention
- Avoid BIT/JSON/spatial columns in tool output or cast to CHAR
- Align driver version with converter expectations
- Smoke-test each query's result types
- Prefer explicit type names in SELECT lists
When it happens
Trigger: RunSQL returns rows whose driver values cannot be mapped by mysqlcommon.ConvertToType for the detected column type (unsupported type byte or malformed value).
Common situations: Legacy MySQL-driver type codes from OceanBase that the shared converter does not handle; corrupted or out-of-range temporal/numeric values; driver version mismatch between column type detection and converter support.
Related errors
- errors encountered when converting values: %w
- unable to create pool: %w
- unable to connect successfully: %w
- unable to parse row: %w
- unable to parse row: %w
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/11711c0bba9e35dc.
Report an issue: GitHub.