googleapis/mcp-toolbox · error
unable to parse row: %w
Error message
unable to parse row: %w
What it means
This error wraps a failure from database/sql's rows.Scan() while reading a result row in the MySQL source's RunSQL tool. The Go MySQL driver could not copy a column value from the current row into the destination buffer (rawValues). It almost always indicates a value/type mismatch between what the driver returned and what the scan destinations expect, and the wrapped error names the offending column.
Source
Thrown at internal/sources/mysql/mysql.go:160
}
// 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)
}
out := []any{}
for results.Next() {
err := results.Scan(values...)
if err != nil {
return nil, fmt.Errorf("unable to parse row: %w", err)
}
row := orderedmap.Row{}
for i, name := range cols {
val := rawValues[i]
if val == nil {
row.Add(name, nil)
continue
}
convertedValue, err := mysqlcommon.ConvertToType(colTypes[i], val)
if err != nil {
return nil, fmt.Errorf("errors encountered when converting values: %w", err)
}
row.Add(name, convertedValue)
}
out = append(out, row)
}
View on GitHub (pinned to 8cc6e09de2)
Solutions
- Read the wrapped error to identify the failing column and cast/convert it in SQL (e.g. CAST(col AS CHAR), HEX() for binary).
- Upgrade the github.com/go-sql-driver/mysql dependency to the latest version.
- Test the same query with a plain MySQL client to confirm the data itself is valid.
- If BIT columns are the cause, select them as col+0 or CAST(col AS UNSIGNED).
Example fix
// before SELECT flags FROM permissions; // after SELECT CAST(flags AS UNSIGNED) AS flags FROM permissions;
Defensive patterns
Strategy: try-catch
Validate before calling
// Validate the query result types before running through the tool:
rows, err := db.QueryContext(ctx, "SELECT flags FROM permissions LIMIT 1")
if err != nil { return err }
ctypes, err := rows.ColumnTypes()
if err != nil { return err }
for _, ct := range ctypes {
fmt.Println(ct.Name(), ct.DatabaseTypeName()) // flag exotic types (BIT, GEOMETRY) and CAST them in SQL
} Try / catch
out, err := toolboxClient.InvokeTool(ctx, "run-sql", params)
if err != nil {
var parseErr *parseRowError // or match on the wrapped driver error
if strings.Contains(err.Error(), "unable to parse row") {
// inspect wrapped cause, adjust SQL casts, and retry once
}
return err
} Prevention
- Avoid selecting exotic types (BIT, GEOMETRY, BLOB) directly; CAST or HEX them in SQL.
- Keep the go-sql-driver/mysql dependency up to date.
- Test queries against a plain mysql client before wiring them into the tool.
- Pin MySQL server and driver versions to a known-compatible pair.
When it happens
Trigger: Executing a query via the mysql run-sql tool whose result contains a value the driver cannot scan into the []byte/raw destination (e.g. certain BIT, unusual geometry, or corrupted binary values), or a driver/serve version mismatch causing column type descriptors the scanner cannot handle.
Common situations: Selecting exotic column types (BIT(M>1), GEOMETRY, malformed JSON), querying a proxy or older MySQL/MariaDB server with divergent protocol types, or data truncated by server-side max_allowed_packet issues.
Understand the failure class
- Parsing and encoding errors: unexpected token, malformed input — why parsers reject input and how to find the real culprit.
Related errors
- errors encountered when converting values: %w
- unable to parse row: %w
- unable to create pool: %w
- unable to connect successfully: %w
- unable to execute query: %w
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/48824e869058aa3e.
Report an issue: GitHub.