{"id":"096f258ce0c37be8","repo":"jackc/pgx","slug":"cannot-scan-null-into-t-096f25","errorCode":null,"errorMessage":"cannot scan NULL into %T","messagePattern":"cannot scan NULL into %T","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/pgtype.go","lineNumber":412,"sourceCode":"\tscanner := dst.(sql.Scanner)\n\n\tswitch {\n\tcase src == nil:\n\t\t// This is necessary because interface value []byte:nil does not equal nil:nil for the binary format path and the\n\t\t// text format path would be converted to empty string.\n\t\treturn scanner.Scan(nil)\n\tcase plan.formatCode == BinaryFormatCode:\n\t\treturn scanner.Scan(src)\n\tdefault:\n\t\treturn scanner.Scan(string(src))\n\t}\n}\n\ntype scanPlanString struct{}\n\nfunc (scanPlanString) Scan(src []byte, dst any) error {\n\tif src == nil {\n\t\treturn fmt.Errorf(\"cannot scan NULL into %T\", dst)\n\t}\n\n\tp := (dst).(*string)\n\t*p = string(src)\n\treturn nil\n}\n\ntype scanPlanAnyTextToBytes struct{}\n\nfunc (scanPlanAnyTextToBytes) Scan(src []byte, dst any) error {\n\tdstBuf := dst.(*[]byte)\n\tif src == nil {\n\t\t*dstBuf = nil\n\t\treturn nil\n\t}\n\n\t*dstBuf = make([]byte, len(src))\n\tcopy(*dstBuf, src)","sourceCodeStart":394,"sourceCodeEnd":430,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/pgtype.go#L394-L430","documentation":"Error \"cannot scan NULL into %T\" thrown in jackc/pgx.","triggerScenarios":"Thrown at pgtype/pgtype.go:412 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}