{"record":{"id":"77c7dc1d3c6d546f","repo":"jackc/pgx","slug":"invalid-length-for-polygon-with-d-points-w","errorCode":null,"errorMessage":"invalid length for Polygon with %d points: %w","messagePattern":"invalid length for Polygon with (.+?) points: %w","errorType":"error_code","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/polygon.go","lineNumber":181,"sourceCode":"\t}\n\n\tr := pgio.NewReader(src)\n\n\t// Each point is two float64s.\n\tpointCount := r.Count(16)\n\tif err := r.Err(); err != nil {\n\t\treturn fmt.Errorf(\"invalid length for polygon: %w\", err)\n\t}\n\n\tpoints := make([]Vec2, pointCount)\n\tfor i := range points {\n\t\tx := r.Uint64()\n\t\ty := r.Uint64()\n\t\tpoints[i] = Vec2{math.Float64frombits(x), math.Float64frombits(y)}\n\t}\n\n\tif err := r.Finish(); err != nil {\n\t\treturn fmt.Errorf(\"invalid length for Polygon with %d points: %w\", pointCount, err)\n\t}\n\n\treturn scanner.ScanPolygon(Polygon{\n\t\tP:     points,\n\t\tValid: true,\n\t})\n}\n\ntype scanPlanTextAnyToPolygonScanner struct{}\n\nfunc (scanPlanTextAnyToPolygonScanner) Scan(src []byte, dst any) error {\n\tscanner := (dst).(PolygonScanner)\n\n\tif src == nil {\n\t\treturn scanner.ScanPolygon(Polygon{})\n\t}\n\n\tif len(src) < 7 {","sourceCodeStart":163,"sourceCodeEnd":199,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/polygon.go#L163-L199","documentation":"The binary polygon payload contained more bytes than needed for the parsed point count: after reading pointCount*16 bytes of coordinates, r.Finish() reports trailing bytes. The message includes how many points were parsed before the mismatch was detected.","triggerScenarios":"Thrown at pgtype/polygon.go:181 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Treat the row value as corrupt and fail the scan; do not use the partially parsed points","Verify no codec or transport layer is appending padding to binary values","Capture the raw payload for diagnosis of the length mismatch"],"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"}