{"record":{"id":"eb708f3147dbbf54","repo":"jackc/pgx","slug":"too-many-fields","errorCode":null,"errorMessage":"too many fields","messagePattern":"too many fields","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgproto3/row_description.go","lineNumber":107,"sourceCode":"\t\tfd.DataTypeSize = int16(binary.BigEndian.Uint16(src[rp:]))\n\t\trp += 2\n\t\tfd.TypeModifier = int32(binary.BigEndian.Uint32(src[rp:]))\n\t\trp += 4\n\t\tfd.Format = int16(binary.BigEndian.Uint16(src[rp:]))\n\t\trp += 2\n\n\t\tdst.Fields = append(dst.Fields, fd)\n\t}\n\n\treturn nil\n}\n\n// Encode encodes src into dst. dst will include the 1 byte message type identifier and the 4 byte message length.\nfunc (src *RowDescription) Encode(dst []byte) ([]byte, error) {\n\tdst, sp := beginMessage(dst, 'T')\n\n\tif len(src.Fields) > math.MaxUint16 {\n\t\treturn nil, errors.New(\"too many fields\")\n\t}\n\tdst = pgio.AppendUint16(dst, uint16(len(src.Fields)))\n\tfor _, fd := range src.Fields {\n\t\tdst = append(dst, fd.Name...)\n\t\tdst = append(dst, 0)\n\n\t\tdst = pgio.AppendUint32(dst, fd.TableOID)\n\t\tdst = pgio.AppendUint16(dst, fd.TableAttributeNumber)\n\t\tdst = pgio.AppendUint32(dst, fd.DataTypeOID)\n\t\tdst = pgio.AppendInt16(dst, fd.DataTypeSize)\n\t\tdst = pgio.AppendInt32(dst, fd.TypeModifier)\n\t\tdst = pgio.AppendInt16(dst, fd.Format)\n\t}\n\n\treturn finishMessage(dst, sp)\n}\n\n// MarshalJSON implements encoding/json.Marshaler.","sourceCodeStart":89,"sourceCodeEnd":125,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgproto3/row_description.go#L89-L125","documentation":"Encode-time guard in the RowDescription wire message encoder: the number of field descriptors exceeds math.MaxUint16, since the protocol encodes the field count in an unsigned 16-bit field. A result set with more than 65535 columns is the faulty input — far beyond any real query.","triggerScenarios":"Thrown at pgproto3/row_description.go:107 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Reduce the result set to at most 65535 columns (e.g. SELECT fewer columns or use *)","Redesign the schema/query producing an extremely wide result"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"ec1a0befd22592cffffdeeb0a50311b506372f4c","analyzedAt":"2026-08-04T22:52:11.263Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}