{"record":{"id":"6921ab2b83e9f0dc","repo":"jackc/pgx","slug":"invalid-format-for-lseg","errorCode":null,"errorMessage":"invalid format for lseg","messagePattern":"invalid format for lseg","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/lseg.go","lineNumber":189,"sourceCode":"}\n\ntype scanPlanTextAnyToLsegScanner struct{}\n\nfunc (scanPlanTextAnyToLsegScanner) Scan(src []byte, dst any) error {\n\tscanner := (dst).(LsegScanner)\n\n\tif src == nil {\n\t\treturn scanner.ScanLseg(Lseg{})\n\t}\n\n\tif len(src) < 11 {\n\t\treturn fmt.Errorf(\"invalid length for lseg: %v\", len(src))\n\t}\n\n\t// Expected format: [(x1,y1),(x2,y2)]\n\tsp1, sp2, found := strings.Cut(string(src[2:len(src)-2]), \"),(\")\n\tif !found {\n\t\treturn fmt.Errorf(\"invalid format for lseg\")\n\t}\n\n\tsx1, sy1, found := strings.Cut(sp1, \",\")\n\tif !found {\n\t\treturn fmt.Errorf(\"invalid format for lseg\")\n\t}\n\tsx2, sy2, found := strings.Cut(sp2, \",\")\n\tif !found {\n\t\treturn fmt.Errorf(\"invalid format for lseg\")\n\t}\n\n\tx1, err := strconv.ParseFloat(sx1, 64)\n\tif err != nil {\n\t\treturn err\n\t}\n\ty1, err := strconv.ParseFloat(sy1, 64)\n\tif err != nil {\n\t\treturn err","sourceCodeStart":171,"sourceCodeEnd":207,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/lseg.go#L171-L207","documentation":"Parsing the textual lseg form '[(x1,y1),(x2,y2)]' proceeds in stages: split the two points on '),(', then split each point on ','. This guard fires at any stage where the expected separator is missing, i.e. the inner content is not structured as two comma-separated coordinate pairs.","triggerScenarios":"Thrown at pgtype/lseg.go:189 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Store lseg values in canonical '[(x1,y1),(x2,y2)]' format","Validate and normalize strings before writing them to the column","Use binary format encoding for lseg columns"],"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"}