{"record":{"id":"c249841c7de37e01","repo":"jackc/pgx","slug":"read-past-end-of-composite","errorCode":null,"errorMessage":"read past end of composite","messagePattern":"read past end of composite","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/composite.go","lineNumber":158,"sourceCode":"\tfor i, field := range plan.cc.Fields {\n\t\tif scanner.Next() {\n\t\t\tfieldTarget, err := compositeFieldTarget(targetScanner, i)\n\t\t\tif err != nil {\n\t\t\t\treturn err\n\t\t\t}\n\t\t\tif fieldTarget != nil {\n\t\t\t\tfieldPlan := plan.m.PlanScan(field.Type.OID, BinaryFormatCode, fieldTarget)\n\t\t\t\tif fieldPlan == nil {\n\t\t\t\t\treturn fmt.Errorf(\"unable to encode %v into OID %d in binary format\", field, field.Type.OID)\n\t\t\t\t}\n\n\t\t\t\terr = fieldPlan.Scan(scanner.Bytes(), fieldTarget)\n\t\t\t\tif err != nil {\n\t\t\t\t\treturn err\n\t\t\t\t}\n\t\t\t}\n\t\t} else {\n\t\t\treturn errors.New(\"read past end of composite\")\n\t\t}\n\t}\n\n\tif err := scanner.Err(); err != nil {\n\t\treturn err\n\t}\n\n\treturn nil\n}\n\ntype scanPlanTextCompositeToCompositeIndexScanner struct {\n\tcc *CompositeCodec\n\tm  *Map\n}\n\nfunc (plan *scanPlanTextCompositeToCompositeIndexScanner) Scan(src []byte, target any) error {\n\ttargetScanner := (target).(CompositeIndexScanner)\n","sourceCodeStart":140,"sourceCodeEnd":176,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/composite.go#L140-L176","documentation":"Composite-type scan guard: the registered composite type declares more fields than the binary representation being decoded contains — the field scanner ran out of bytes before all planned fields were read. The mismatch is between the composite type registered on the Go side and the data sent by the server (usually a stale registration after an ALTER TYPE).","triggerScenarios":"Thrown at pgtype/composite.go:158 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Re-register the composite type so its field list matches the server's current definition","Verify the column really holds the expected composite type","Check that null fields are represented per the binary composite format"],"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"}