{"record":{"id":"81cc73891e14b97f","repo":"googleapis/mcp-toolbox","slug":"unable-to-parse-row-w","errorCode":null,"errorMessage":"unable to parse row: %w","messagePattern":"unable to parse row: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/sources/alloydbpg/alloydb_pg.go","lineNumber":131,"sourceCode":"\nfunc (s *Source) PostgresPool() *pgxpool.Pool {\n\treturn s.Pool\n}\n\nfunc (s *Source) RunSQL(ctx context.Context, statement string, params []any) (any, error) {\n\tstatement = sqlcommenter.PrependComment(ctx, statement, SourceType, s.SQLCommenter)\n\tresults, err := s.Pool.Query(ctx, statement, params...)\n\tif err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to execute query: %w\", err)\n\t}\n\tdefer results.Close()\n\n\tfields := results.FieldDescriptions()\n\tout := []any{}\n\tfor results.Next() {\n\t\tv, err := results.Values()\n\t\tif err != nil {\n\t\t\treturn nil, fmt.Errorf(\"unable to parse row: %w\", err)\n\t\t}\n\t\trow := orderedmap.Row{}\n\t\tfor i, f := range fields {\n\t\t\tval := sources.NormalizeValue(v[i], f.DataTypeOID)\n\t\t\trow.Add(f.Name, val)\n\t\t}\n\t\tout = append(out, row)\n\t}\n\t// this will catch actual query execution errors\n\tif err := results.Err(); err != nil {\n\t\treturn nil, fmt.Errorf(\"unable to execute query: %w\", err)\n\t}\n\treturn out, nil\n}\n\nfunc getOpts(ipType, userAgent string, useIAM bool) ([]alloydbconn.Option, error) {\n\topts := []alloydbconn.Option{alloydbconn.WithUserAgent(userAgent)}\n\tswitch strings.ToLower(ipType) {","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/googleapis/mcp-toolbox/blob/8cc6e09de2ad7b8bffc77751799585a1401a48eb/internal/sources/alloydbpg/alloydb_pg.go#L113-L149","documentation":"While streaming query results, RunSQL calls results.Values() for each row. This error wraps a failure decoding a row's column values into Go representations (pgx type decoding), which happens after the query has started successfully.","triggerScenarios":"A result row contains a column value that pgx cannot decode into its expected Go type — typically custom/composite/enum types with unusual OIDs, corrupted values, or driver-type-mapping mismatches.","commonSituations":"Selecting exotic custom types or domains, tables with user-defined types not registered with the driver, or bytea/geometry values with encoding issues during result streaming.","solutions":["Identify the failing column from the wrapped error and cast it in SQL (e.g. `col::text`).","Avoid SELECT * on tables with exotic custom types; select needed columns explicitly.","Register custom types or update the pgx/pgconn driver versions for better type coverage.","Retry the query if the error was transient (e.g. during a concurrent DDL change)."],"exampleFix":"// before\nSELECT * FROM sensors;\n// after\nSELECT id, name, reading::text AS reading FROM sensors;","handlingStrategy":"try-catch","validationCode":"-- Check for exotic column types before SELECT *\nSELECT column_name, data_type, udt_name FROM information_schema.columns\nWHERE table_name = 'my_table' AND udt_name NOT IN (\n  'int2','int4','int8','float4','float8','numeric','bool','text','varchar','bpchar','date','timestamp','timestamptz','uuid','bytea','json','jsonb');","typeGuard":null,"tryCatchPattern":"out, err := src.RunSQL(ctx, stmt, params)\nif err != nil && strings.Contains(err.Error(), \"unable to parse row\") {\n    // retry with casts to text for custom-typed columns\n    stmt = rewriteWithCasts(stmt)\n    out, err = src.RunSQL(ctx, stmt, params)\n}","preventionTips":["Avoid SELECT * on tables with custom/extension types","Cast unusual columns to text in tool-defined SQL","Keep pgx/pgconn driver versions current","Register custom types with the driver if reused in-app"],"tags":["go","sql","postgres","row-decoding","pgx"],"backgroundTag":"row-decode-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"}