{"record":{"id":"b7bd83833cc392d2","repo":"jackc/pgx","slug":"composite-text-format-must-start-with","errorCode":null,"errorMessage":"composite text format must start with '('","messagePattern":"composite text format must start with '\\('","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/composite.go","lineNumber":376,"sourceCode":"}\n\ntype CompositeTextScanner struct {\n\tm   *Map\n\trp  int\n\tsrc []byte\n\n\tfieldBytes []byte\n\terr        error\n}\n\n// NewCompositeTextScanner a scanner over a text encoded composite value.\nfunc NewCompositeTextScanner(m *Map, src []byte) *CompositeTextScanner {\n\tif len(src) < 2 {\n\t\treturn &CompositeTextScanner{err: fmt.Errorf(\"Record incomplete %v\", src)}\n\t}\n\n\tif src[0] != '(' {\n\t\treturn &CompositeTextScanner{err: fmt.Errorf(\"composite text format must start with '('\")}\n\t}\n\n\tif src[len(src)-1] != ')' {\n\t\treturn &CompositeTextScanner{err: fmt.Errorf(\"composite text format must end with ')'\")}\n\t}\n\n\treturn &CompositeTextScanner{\n\t\tm:   m,\n\t\trp:  1,\n\t\tsrc: src,\n\t}\n}\n\n// Next advances the scanner to the next field. It returns false after the last field is read or an error occurs. After\n// Next returns false, the Err method can be called to check if any errors occurred.\nfunc (cfs *CompositeTextScanner) Next() bool {\n\tif cfs.err != nil {\n\t\treturn false","sourceCodeStart":358,"sourceCodeEnd":394,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/composite.go#L358-L394","documentation":"Returned by NewCompositeTextScanner when the textual composite value does not begin with '('. PostgreSQL's composite text output is always parenthesized, so a different first byte means the data is not a composite literal.","triggerScenarios":"Thrown at pgtype/composite.go:376 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Supply composite text in PostgreSQL's '(field1,field2)' format","Cast or re-type the source column to the composite type"],"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"}