googleapis/mcp-toolbox · error

unable to parse row: %w

Error message

unable to parse row: %w

What it means

RunSQL wraps results.Scan(values...) errors with this message. Scan failed while copying a row's column values into the pre-allocated []any slots — the driver could not convert a server value into the destination representation, or the row shape did not match the column count.

Source

Thrown at internal/sources/singlestore/singlestore.go:143

	// 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)
	}

	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
			}

			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 {

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Read the wrapped Scan error to identify which column/value failed.
  2. Cast problematic columns explicitly in SQL (e.g. CAST(col AS CHAR)) to a well-supported type.
  3. Check for driver/version incompatibilities and update go-sql-driver/mysql.
  4. Test the same query via the `mysql` CLI to confirm server-side data is valid.
  5. If a specific column type always fails, avoid SELECT * and select only supported columns.

Example fix

// before
SELECT * FROM events
// after (cast problematic column)
SELECT id, CAST(geom AS CHAR) AS geom FROM events
Defensive patterns

Strategy: validation

Validate before calling

-- Pre-check column types before running the tool
SHOW COLUMNS FROM my_table;
-- Replace unsupported types in the query:
-- SELECT id, CAST(weird_col AS CHAR) AS weird_col FROM my_table

Try / catch

out, err := source.RunSQL(ctx, stmt, params)
if err != nil {
    var scanErr error
    if strings.Contains(err.Error(), "unable to parse row") {
        scanErr = fmt.Errorf("row decode failed; cast unsupported columns: %w", err)
    }
    return out, scanErr
}

Prevention

When it happens

Trigger: results.Next() returned a row and Scan failed, e.g. a driver-level decode failure for a value type, NULL handling mismatch, or column count/destination length mismatch.

Common situations: Unusual SingleStore column types (e.g. large decimals, JSON, geometry) the MySQL driver struggles to scan into a plain any slot; corrupt/aborted result stream; server version producing unexpected wire types.

Understand the failure class

Related errors


AI-assisted analysis of googleapis/mcp-toolbox@8cc6e09de2 (2026-09-05). Data as JSON: /api/errors/30f5141088d682db. Report an issue: GitHub.