googleapis/mcp-toolbox · error
unable to scan row: %w
Error message
unable to scan row: %w
What it means
sqlite RunSQL (internal/sources/sqlite/sqlite.go:131) scans each result row into a slice of raw any values (using generic destinations because the sqlite driver lacks ColumnTypes). A scan failure is wrapped as "unable to scan row". This happens when the driver cannot convert a column value into *any, which is uncommon but can occur with driver-specific value handling errors.
Source
Thrown at internal/sources/sqlite/sqlite.go:131
cols, err := rows.Columns()
if err != nil {
return nil, fmt.Errorf("unable to get column names: %w", err)
}
// The sqlite driver does not support ColumnTypes, so we can't get the
// underlying database type of the columns. We'll have to rely on the
// generic `any` type and then handle the JSON data separately.
rawValues := make([]any, len(cols))
values := make([]any, len(cols))
for i := range rawValues {
values[i] = &rawValues[i]
}
// Prepare the result slice
out := []any{}
for rows.Next() {
if err := rows.Scan(values...); err != nil {
return nil, fmt.Errorf("unable to scan row: %w", err)
}
// Create a map for this row
row := orderedmap.Row{}
for i, name := range cols {
val := rawValues[i]
// Handle nil values
if val == nil {
row.Add(name, nil)
continue
}
// Handle JSON data
if jsonString, ok := val.(string); ok {
var unmarshaledData any
if json.Unmarshal([]byte(jsonString), &unmarshaledData) == nil {
row.Add(name, unmarshaledData)
continue
}View on GitHub (pinned to 8cc6e09de2)
Solutions
- Identify the offending row via the wrapped error and inspect that column's data
- Cast problematic columns in SQL: SELECT CAST(bigblob_col AS TEXT) ...
- Update the sqlite driver (modernc.org/sqlite or mattn/go-sqlite3) to the latest version
- Run PRAGMA integrity_check to rule out database corruption
Example fix
// before SELECT blob_data FROM files; // after SELECT CAST(blob_data AS TEXT) AS blob_data FROM files;
Defensive patterns
Strategy: validation
Validate before calling
// pre-check unusual column values
row := db.QueryRow("SELECT typeof(col) FROM t LIMIT 1")
var t string
row.Scan(&t) // ensure the type is one your flow can handle Prevention
- CAST large/BLOB columns to TEXT in SQL
- Keep the sqlite driver updated
- Run PRAGMA integrity_check if corruption is suspected
When it happens
Trigger: RunSQL where rows.Scan(values...) fails on a row — typically a driver conversion failure for an unusual column value/type, or a rows.Next/Scan state violation.
Common situations: Very large BLOB or nonstandard values; driver-specific scan bugs; corruption in a row; using a driver fork with different Scan semantics.
Related errors
- unable to parse row: %w
- unable to parse row: %w
- unable to parse row: %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/9065e05bed117ca0.
Report an issue: GitHub.