{"record":{"id":"8e5206a887313082","repo":"jackc/pgx","slug":"array-header-w","errorCode":null,"errorMessage":"array header: %w","messagePattern":"array header: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/array.go","lineNumber":51,"sourceCode":"\t}\n\n\telementCount := int(dimensions[0].Length)\n\tfor _, d := range dimensions[1:] {\n\t\telementCount *= int(d.Length)\n\t}\n\n\tif elementCount < 0 {\n\t\treturn 0\n\t}\n\n\treturn elementCount\n}\n\nfunc (dst *arrayHeader) DecodeBinary(r *pgio.Reader) error {\n\t// Each dimension is 8 bytes, which also bounds the Dimensions allocation below.\n\tnumDims := r.Count(8)\n\tif err := r.Err(); err != nil {\n\t\treturn fmt.Errorf(\"array header: %w\", err)\n\t}\n\n\tif numDims > 6 {\n\t\treturn fmt.Errorf(\"array has too many dimensions: %d\", numDims)\n\t}\n\n\tdst.ContainsNull = r.Uint32() == 1\n\tdst.ElementOID = r.Uint32()\n\n\tdst.Dimensions = make([]ArrayDimension, numDims)\n\tfor i := range dst.Dimensions {\n\t\tdst.Dimensions[i].Length = r.Int32()\n\t\tdst.Dimensions[i].LowerBound = r.Int32()\n\t}\n\n\tif err := r.Err(); err != nil {\n\t\treturn fmt.Errorf(\"array header: %w\", err)\n\t}","sourceCodeStart":33,"sourceCodeEnd":69,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/array.go#L33-L69","documentation":"While decoding a binary array, reading the fixed-size header portion failed — the buffer ran short or the reader errored. The wrapped error is from the pgio reader, typically unexpected EOF on truncated array data.","triggerScenarios":"Thrown at pgtype/array.go:51 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the binary array data is complete and not truncated","Check that the column actually contains an array type","Inspect the wrapped error for the reader's specific failure","Test with a simple array value to isolate the issue"],"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"}