googleapis/mcp-toolbox · error

unable to parse row: %w

Error message

unable to parse row: %w

What it means

OceanBase RunSQL scans each row of a query result into pre-allocated value holders; when database/sql's Scan cannot convert a column value into the target Go type (e.g. a NULL into a non-nullable holder or a type mismatch), it wraps the driver error with this message.

Source

Thrown at internal/sources/oceanbase/oceanbase.go:134

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

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

View on GitHub (pinned to 8cc6e09de2)

Solutions

  1. Check the wrapped %w driver error to identify the failing column and value
  2. Adjust the SQL to cast unsupported columns (e.g. CAST(col AS CHAR))
  3. Ensure parseTime=true DSN settings match DATETIME/TIMESTAMP usage
  4. Update the go-sql-driver/mysql and mysqlcommon converters to a version supporting the type

Example fix

// before
SELECT data FROM t;
// after
SELECT CAST(data AS CHAR) AS data FROM t;
Defensive patterns

Strategy: try-catch

Validate before calling

// validate column types before relying on values
rows, _ := db.Query(sql)
cts, _ := rows.ColumnTypes()
for i, ct := range cts {
    if len(ct.ScanType() == nil) > 0 { /* nullable holders required */ }
}

Type guard

func hasNonNull(v any) bool { return v != nil }

Try / catch

out, err := oceanbaseSource.RunSQL(ctx, sql)
if err != nil {
    var scanErr *fmt.WrapError
    if strings.Contains(err.Error(), "unable to parse row") {
        // inspect offending column, adjust SQL casts
    }
    return err
}

Prevention

When it happens

Trigger: Calling the OceanBase RunSQL tool with a query whose returned column value cannot be scanned into rawValues, such as unsupported column types or NULLs where a non-nil target is expected.

Common situations: Queries returning exotic OceanBase/MySQL column types (e.g. BIT, JSON, spatial types) that the go-sql-driver does not decode; schema drift where a column type changed after the query was written.

Understand the failure class

Related errors


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