{"record":{"id":"3ed84c20da1b2b6c","repo":"googleapis/mcp-toolbox","slug":"errors-encountered-when-converting-values-w-3ed84c","errorCode":null,"errorMessage":"errors encountered when converting values: %w","messagePattern":"errors encountered when converting values: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/singlestore/singlestore.go","lineNumber":155,"sourceCode":"\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\tval := rawValues[i]\n\t\t\tif val == nil {\n\t\t\t\tvMap[name] = nil\n\t\t\t\tcontinue\n\t\t\t}\n\n\t\t\tvMap[name], err = mysqlcommon.ConvertToType(colTypes[i], val)\n\t\t\tif err != nil {\n\t\t\t\treturn nil, fmt.Errorf(\"errors encountered when converting values: %w\", err)\n\t\t\t}\n\t\t}\n\t\tout = append(out, vMap)\n\t}\n\n\tif err := results.Err(); err != nil {\n\t\treturn nil, fmt.Errorf(\"errors encountered during row iteration: %w\", err)\n\t}\n\n\treturn out, nil\n}\n\nfunc initSingleStoreConnectionPool(ctx context.Context, tracer trace.Tracer, cfg Config) (*sql.DB, error) {\n\t//nolint:all // Reassigned ctx\n\tctx, span := sources.InitConnectionSpan(ctx, tracer, SourceType, cfg.Name)\n\tdefer span.End()\n\n\t// Build query parameters via url.Values for deterministic order and proper escaping.","sourceCodeStart":137,"sourceCodeEnd":173,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/singlestore/singlestore.go#L137-L173","documentation":"RunSQL wraps mysqlcommon.ConvertToType(colTypes[i], val) errors with this message. After a row is scanned, each column's raw value is converted to a proper Go type based on the column's database type; a failure means a value in the row could not be represented as the expected type.","triggerScenarios":"A scanned value (e.g. []byte, time.Time, decimal string) fails type conversion for its declared column type in ConvertToType — malformed data in the column, or a column type the converter does not support.","commonSituations":"Invalid stored dates/timestamps (e.g. zero dates), numeric overflow for the target Go type, unsupported column types like custom encodings, or NULLs slipping through as non-nil placeholders.","solutions":["Read the wrapped ConvertToType error to find the offending column and value.","Fix or clean the invalid data in the table (e.g. zero-date rows).","CAST the problem column to a simpler type in the SQL statement.","Ensure time zone / parseTime DSN settings match the data (add parseTime=true or loc params via connectionParams).","Check data types are as expected with `DESCRIBE table` and adjust the query."],"exampleFix":"// before\nSELECT * FROM logs\n// after\nSELECT id, CAST(event_time AS CHAR) AS event_time FROM logs","handlingStrategy":"validation","validationCode":"-- Inspect data quality before querying\nSELECT COUNT(*) FROM my_table WHERE ts = '0000-00-00' OR ts IS NULL;\nDESCRIBE my_table;","typeGuard":null,"tryCatchPattern":"out, err := source.RunSQL(ctx, stmt, params)\nif err != nil && strings.Contains(err.Error(), \"errors encountered when converting values\") {\n    // retry with sanitized query that CASTs the offending column\n    out, err = source.RunSQL(ctx, sanitizedStmt, params)\n}","preventionTips":["Clean zero/invalid dates and out-of-range numerics in data","Match parseTime/loc DSN settings to your time data","CAST problem columns in SQL","Run DESCRIBE to confirm expected types"],"tags":["singlestore","sql","types","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"}