{"record":{"id":"083da3537983dfcc","repo":"jackc/pgx","slug":"cannot-scan-null-into-compositefields","errorCode":null,"errorMessage":"cannot scan NULL into CompositeFields","messagePattern":"cannot scan NULL into CompositeFields","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/composite.go","lineNumber":616,"sourceCode":"\treturn src\n}\n\n// CompositeFields represents the values of a composite value. It can be used as an encoding source or as a scan target.\n// It cannot scan a NULL, but the composite fields can be NULL.\ntype CompositeFields []any\n\nfunc (cf CompositeFields) SkipUnderlyingTypePlan() {}\n\nfunc (cf CompositeFields) IsNull() bool {\n\treturn cf == nil\n}\n\nfunc (cf CompositeFields) Index(i int) any {\n\treturn cf[i]\n}\n\nfunc (cf CompositeFields) ScanNull() error {\n\treturn fmt.Errorf(\"cannot scan NULL into CompositeFields\")\n}\n\nfunc (cf CompositeFields) ScanIndex(i int) any {\n\treturn cf[i]\n}\n","sourceCodeStart":598,"sourceCodeEnd":622,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/composite.go#L598-L622","documentation":"Returned by CompositeFields.ScanNull when a NULL composite is scanned into a CompositeFields slice. By design CompositeFields cannot represent an all-NULL record — only its individual fields can be NULL.","triggerScenarios":"Thrown at pgtype/composite.go:616 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Scan into a *CompositeFields pointer to represent a NULL record","Filter NULL composites out of the query"],"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"}