{"id":"4d6d2a4c020ea061","repo":"jackc/pgx","slug":"cannot-scan-into-non-pointer-or-nil-destinations-4d6d2a","errorCode":null,"errorMessage":"cannot scan into non-pointer or nil destinations %T","messagePattern":"cannot scan into non-pointer or nil destinations %T","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/pgtype.go","lineNumber":502,"sourceCode":"}\n\n// TryWrapScanPlanFunc is a function that tries to create a wrapper plan for target. If successful it returns a plan\n// that will convert the target passed to Scan and then call the next plan. nextTarget is target as it will be converted\n// by plan. It must be used to find another suitable ScanPlan. When it is found SetNext must be called on plan for it\n// to be usabled. ok indicates if a suitable wrapper was found.\ntype TryWrapScanPlanFunc func(target any) (plan WrappedScanPlanNextSetter, nextTarget any, ok bool)\n\ntype pointerPointerScanPlan struct {\n\tdstType reflect.Type\n\tnext    ScanPlan\n}\n\nfunc (plan *pointerPointerScanPlan) SetNext(next ScanPlan) { plan.next = next }\n\nfunc (plan *pointerPointerScanPlan) Scan(src []byte, dst any) error {\n\tdstValue := reflect.ValueOf(dst)\n\tif dstValue.Kind() != reflect.Pointer || dstValue.IsNil() {\n\t\treturn fmt.Errorf(\"cannot scan into non-pointer or nil destinations %T\", dst)\n\t}\n\n\tel := dstValue.Elem()\n\tif src == nil {\n\t\tel.Set(reflect.Zero(el.Type()))\n\t\treturn nil\n\t}\n\n\tel.Set(reflect.New(el.Type().Elem()))\n\treturn plan.next.Scan(src, el.Interface())\n}\n\n// TryPointerPointerScanPlan handles a pointer to a pointer by setting the target to nil for SQL NULL and allocating and\n// scanning for non-NULL.\nfunc TryPointerPointerScanPlan(target any) (plan WrappedScanPlanNextSetter, nextTarget any, ok bool) {\n\tif dstType := reflect.TypeOf(target); dstType != nil && dstType.Kind() == reflect.Pointer {\n\t\telemType := dstType.Elem()\n\t\tif elemType.Kind() == reflect.Pointer {","sourceCodeStart":484,"sourceCodeEnd":520,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/pgtype.go#L484-L520","documentation":"Error \"cannot scan into non-pointer or nil destinations %T\" thrown in jackc/pgx.","triggerScenarios":"Thrown at pgtype/pgtype.go:502 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":[],"exampleFix":null,"handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"analyzedSha":"ec1a0befd22592cffffdeeb0a50311b506372f4c","analyzedAt":"2026-08-04T22:52:11.263Z","schemaVersion":2}