{"record":{"id":"47e617ecc9664dad","repo":"googleapis/mcp-toolbox","slug":"unable-to-scan-row-w","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/oracle/oracle.go","lineNumber":206,"sourceCode":"\t\t\t\tif _, scale, ok := colType.DecimalSize(); ok && scale == 0 {\n\t\t\t\t\t// Scale is 0, treat it as an integer.\n\t\t\t\t\tvalues[i] = new(sql.NullInt64)\n\t\t\t\t} else {\n\t\t\t\t\t// Scale is non-zero or unknown, treat\n\t\t\t\t\t// it as a float.\n\t\t\t\t\tvalues[i] = new(sql.NullFloat64)\n\t\t\t\t}\n\t\t\tcase \"DATE\", \"TIMESTAMP\", \"TIMESTAMP WITH TIME ZONE\", \"TIMESTAMP WITH LOCAL TIME ZONE\":\n\t\t\t\tvalues[i] = new(sql.NullTime)\n\t\t\tcase \"JSON\":\n\t\t\t\tvalues[i] = new(sql.RawBytes)\n\t\t\tdefault:\n\t\t\t\tvalues[i] = new(sql.NullString)\n\t\t\t}\n\t\t}\n\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\tvMap := make(map[string]any)\n\t\tfor i, col := range cols {\n\t\t\treceiver := values[i]\n\n\t\t\tswitch v := receiver.(type) {\n\t\t\tcase *sql.NullInt64:\n\t\t\t\tif v.Valid {\n\t\t\t\t\tvMap[col] = v.Int64\n\t\t\t\t} else {\n\t\t\t\t\tvMap[col] = nil\n\t\t\t\t}\n\t\t\tcase *sql.NullFloat64:\n\t\t\t\tif v.Valid {\n\t\t\t\t\tvMap[col] = v.Float64\n\t\t\t\t} else {\n\t\t\t\t\tvMap[col] = nil","sourceCodeStart":188,"sourceCodeEnd":224,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/oracle/oracle.go#L188-L224","documentation":"This error wraps a failure from rows.Scan() in the Oracle read path. RunSQL pre-allocates typed receivers (NullInt64, NullFloat64, NullTime, RawBytes, NullString) based on the reported Oracle column type; Scan fails when the driver cannot convert the wire value into the chosen receiver. Commonly this is a value whose actual type or size mismatches the column-type-based receiver choice.","triggerScenarios":"RunSQL (readOnly=true) scanning a row where: a NUMBER value overflows int64 (scale 0 but huge, e.g. 99999999999999999999), a LOB/CLOB/BLOB column exceeds what the driver will scan into NullString, an INTERVAL or exotic type is returned but the driver's ColumnTypes() name didn't match any known case, or the driver returns nil in a way incompatible with the allocated receiver.","commonSituations":"Selecting very large NUMBER columns (e.g. sequence-generated IDs beyond int64 range); CLOB columns with go-ora returning sizes the driver refuses to convert; DATE/TIMESTAMP values the OCI driver cannot render into time.Time due to session NLS settings; driver version differences changing DatabaseTypeName() strings so the switch misroutes types.","solutions":["Read the wrapped %w driver error to identify which column and conversion failed.","Check for NUMBER columns with scale 0 that exceed int64 range; cast them in SQL (e.g. TO_CHAR) or add a scale to force float handling.","Ensure CLOB/BLOB columns are small enough or cast with DBMS_LOB.SUBSTR / TO_CHAR so they fit the string receiver.","Upgrade or pin the godror/go-ora driver version, since DatabaseTypeName() output varies between driver versions.","Verify session NLS/date formats if timestamps fail to scan; set explicit NLS settings or use TO_CHAR for date columns."],"exampleFix":"// before\nSELECT id, huge_number_col FROM t;\n\n// after: avoid int64 overflow\nSELECT id, TO_CHAR(huge_number_col) AS huge_number_col FROM t;","handlingStrategy":"validation","validationCode":"rows, _ := db.Query(\"SELECT DATA_TYPE, DATA_PRECISION, DATA_SCALE FROM all_tab_columns WHERE table_name = :1 AND column_name = :2\", tbl, col)\n// reject NUMBER columns with scale 0 and precision > 18 before running the query","typeGuard":null,"tryCatchPattern":"out, err := source.RunSQL(ctx, stmt, params, true)\nif err != nil {\n    var scanErr error\n    if errors.As(err, &scanErr) && strings.Contains(err.Error(), \"unable to scan row\") {\n        return fmt.Errorf(\"column type mismatch: cast problematic columns with TO_CHAR or TO_NUMBER in the query: %w\", err)\n    }\n    return err\n}","preventionTips":["Cast huge NUMBER values to strings (TO_CHAR) in queries instead of selecting them raw.","Avoid selecting raw CLOB/BLOB columns in read-only tools; substr them first.","Keep go-ora/godror driver versions pinned and tested with your schema.","Check all_tab_columns for scale-0 NUMBER columns exceeding int64 range."],"tags":["oracle","database-sql","row-scan","type-conversion"],"backgroundTag":"row-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"}