{"record":{"id":"ce95d64b28fb4362","repo":"googleapis/mcp-toolbox","slug":"unable-to-parse-row-w-ce95d6","errorCode":null,"errorMessage":"unable to parse row: %w","messagePattern":"unable to parse row: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/clickhouse/clickhouse.go","lineNumber":140,"sourceCode":"\t}\n\n\t// create an array of values for each column, which can be re-used to scan each row\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\tcolTypes, err := results.ColumnTypes()\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to get column types: %w\", err)\n\t}\n\n\tout := []any{}\n\tfor results.Next() {\n\t\terr := results.Scan(values...)\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"unable to parse row: %w\", err)\n\t\t}\n\t\tvMap := make(map[string]any)\n\t\tfor i, name := range cols {\n\t\t\t// ClickHouse driver may return specific types that need handling\n\t\t\tswitch colTypes[i].DatabaseTypeName() {\n\t\t\tcase \"String\", \"FixedString\":\n\t\t\t\tif rawValues[i] != nil {\n\t\t\t\t\t// Handle potential []byte to string conversion if needed\n\t\t\t\t\tif b, ok := rawValues[i].([]byte); ok {\n\t\t\t\t\t\tvMap[name] = string(b)\n\t\t\t\t\t} else {\n\t\t\t\t\t\tvMap[name] = rawValues[i]\n\t\t\t\t\t}\n\t\t\t\t} else {\n\t\t\t\t\tvMap[name] = nil\n\t\t\t\t}\n\t\t\tdefault:\n\t\t\t\tvMap[name] = rawValues[i]","sourceCodeStart":122,"sourceCodeEnd":158,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/clickhouse/clickhouse.go#L122-L158","documentation":"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.","triggerScenarios":"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.","commonSituations":"NULL values in non-pointer targets, exotic column types not handled by the switch on DatabaseTypeName, driver type mapping changes after upgrade.","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."],"exampleFix":"// before\nSELECT amount FROM orders -- Decimal\n// after\nSELECT toString(amount) AS amount FROM orders","handlingStrategy":"try-catch","validationCode":"// prefer SQL-side casts so values scan cleanly:\n// SELECT toString(uuid_col), toFloat64(dec_col) FROM t","typeGuard":null,"tryCatchPattern":"rows, err := src.RunSQL(ctx, stmt)\nif err != nil {\n    if strings.Contains(err.Error(), \"unable to parse row\") {\n        return fmt.Errorf(\"scan failed: %w\", err) // fix SQL casts or type handling\n    }\n    return err\n}","preventionTips":["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."],"tags":["clickhouse","scan","row-parsing","type-mapping"],"backgroundTag":"scan-type-mismatch","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"}