googleapis/mcp-toolbox · error
unable to parse row: %w
Error message
unable to parse row: %w
What it means
During row iteration, results.Scan(values...) failed for a particular row. RunSQL wraps it as 'unable to parse row', meaning a value in the result could not be scanned into the generic any placeholders, or type-conversion handling for the column type failed.
Source
Thrown at internal/sources/clickhouse/clickhouse.go:140
}
// 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)
}
vMap := make(map[string]any)
for i, name := range cols {
// ClickHouse driver may return specific types that need handling
switch colTypes[i].DatabaseTypeName() {
case "String", "FixedString":
if rawValues[i] != nil {
// Handle potential []byte to string conversion if needed
if b, ok := rawValues[i].([]byte); ok {
vMap[name] = string(b)
} else {
vMap[name] = rawValues[i]
}
} else {
vMap[name] = nil
}
default:
vMap[name] = rawValues[i]View on GitHub (pinned to 8cc6e09de2)
Solutions
- Look at the wrapped scan error to find the offending column/type.
- Add handling for the column type in the DatabaseTypeName switch in RunSQL.
- Cast/COALESCE problematic columns in SQL (e.g. toString(col), toNullable(col)).
- Upgrade or pin the clickhouse-go driver to a version with correct type mapping.
Example fix
// before SELECT amount FROM orders -- Decimal // after SELECT toString(amount) AS amount FROM orders
Defensive patterns
Strategy: try-catch
Validate before calling
// prefer SQL-side casts so values scan cleanly: // SELECT toString(uuid_col), toFloat64(dec_col) FROM t
Try / catch
rows, err := src.RunSQL(ctx, stmt)
if err != nil {
if strings.Contains(err.Error(), "unable to parse row") {
return fmt.Errorf("scan failed: %w", err) // fix SQL casts or type handling
}
return err
} Prevention
- Cast exotic types (Decimal, UUID, arrays) in SQL.
- Use toNullable()/COALESCE for NULL-heavy columns.
- Keep the DatabaseTypeName switch in RunSQL in sync with your schema types.
When it happens
Trigger: Scanning a row whose column value doesn't fit the expected Go type — e.g. unusual ClickHouse types (Decimal, UUID, arrays) returned by the driver in a form the scan targets can't hold.
Common situations: NULL values in non-pointer targets, exotic column types not handled by the switch on DatabaseTypeName, driver type mapping changes after upgrade.
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
- unable to parse row: %w
- unable to parse row: %w
- unknow param type %s
- fail to get map params: %w
- unable to parse rows: %w
AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05).
Data as JSON: /api/errors/ce95d64b28fb4362.
Report an issue: GitHub.