{"record":{"id":"ce463f69b2041b4f","repo":"jackc/pgx","slug":"invalid-length-for-polygon-v","errorCode":null,"errorMessage":"invalid length for Polygon: %v","messagePattern":"invalid length for Polygon: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/polygon.go","lineNumber":200,"sourceCode":"\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 {\n\t\treturn fmt.Errorf(\"invalid length for Polygon: %v\", len(src))\n\t}\n\n\tpoints := make([]Vec2, 0)\n\n\t// Expected format: ((x1,y1),...,(xn,yn))\n\tstr := string(src[1 : len(src)-1])\n\n\tfor {\n\t\tif len(str) == 0 || str[0] != '(' {\n\t\t\treturn fmt.Errorf(\"invalid format for Polygon\")\n\t\t}\n\t\tbody, rest, found := strings.Cut(str[1:], \")\")\n\t\tif !found {\n\t\t\treturn fmt.Errorf(\"invalid format for Polygon\")\n\t\t}\n\n\t\tsx, sy, found := strings.Cut(body, \",\")\n\t\tif !found {","sourceCodeStart":182,"sourceCodeEnd":218,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/polygon.go#L182-L218","documentation":"The text-form polygon source is shorter than the minimum 7 bytes required for even a single-point polygon \"((x,y))\". The guard fires before any parsing, so the input is structurally too short to be a valid PostgreSQL polygon literal.","triggerScenarios":"Thrown at pgtype/polygon.go:200 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check the source string for truncation before scanning","Ensure the database column actually contains polygon values and not empty or unrelated strings","Log the offending input to find where the bad value originates"],"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"}