{"record":{"id":"9065e05bed117ca0","repo":"googleapis/mcp-toolbox","slug":"unable-to-scan-row-w-9065e0","errorCode":null,"errorMessage":"unable to scan row: %w","messagePattern":"unable to scan row: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/sqlite/sqlite.go","lineNumber":131,"sourceCode":"\tcols, err := rows.Columns()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to get column names: %w\", err)\n\t}\n\n\t// The sqlite driver does not support ColumnTypes, so we can't get the\n\t// underlying database type of the columns. We'll have to rely on the\n\t// generic `any` type and then handle the JSON data separately.\n\trawValues := make([]any, len(cols))\n\tvalues := make([]any, len(cols))\n\tfor i := range rawValues {\n\t\tvalues[i] = &rawValues[i]\n\t}\n\n\t// Prepare the result slice\n\tout := []any{}\n\tfor rows.Next() {\n\t\tif err := rows.Scan(values...); err != nil {\n\t\t\treturn nil, fmt.Errorf(\"unable to scan row: %w\", err)\n\t\t}\n\n\t\t// Create a map for this row\n\t\trow := orderedmap.Row{}\n\t\tfor i, name := range cols {\n\t\t\tval := rawValues[i]\n\t\t\t// Handle nil values\n\t\t\tif val == nil {\n\t\t\t\trow.Add(name, nil)\n\t\t\t\tcontinue\n\t\t\t}\n\t\t\t// Handle JSON data\n\t\t\tif jsonString, ok := val.(string); ok {\n\t\t\t\tvar unmarshaledData any\n\t\t\t\tif json.Unmarshal([]byte(jsonString), &unmarshaledData) == nil {\n\t\t\t\t\trow.Add(name, unmarshaledData)\n\t\t\t\t\tcontinue\n\t\t\t\t}","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/sqlite/sqlite.go#L113-L149","documentation":"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.","triggerScenarios":"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.","commonSituations":"Very large BLOB or nonstandard values; driver-specific scan bugs; corruption in a row; using a driver fork with different Scan semantics.","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"],"exampleFix":"// before\nSELECT blob_data FROM files;\n// after\nSELECT CAST(blob_data AS TEXT) AS blob_data FROM files;","handlingStrategy":"validation","validationCode":"// pre-check unusual column values\nrow := db.QueryRow(\"SELECT typeof(col) FROM t LIMIT 1\")\nvar t string\nrow.Scan(&t) // ensure the type is one your flow can handle","typeGuard":null,"tryCatchPattern":null,"preventionTips":["CAST large/BLOB columns to TEXT in SQL","Keep the sqlite driver updated","Run PRAGMA integrity_check if corruption is suspected"],"tags":["sqlite","scan","rows"],"backgroundTag":"row-scan-failed","analyzedSha":"8cc6e09de2ad7b8bffc77751799585a1401a48eb","analyzedAt":"2026-09-05T01:10:36.887Z","contentChangedAt":"2026-09-05T01:10:36.887Z","schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}