{"record":{"id":"d33dfbfbf096f2f1","repo":"jackc/pgx","slug":"cannot-scan-t-d33dfb","errorCode":null,"errorMessage":"cannot scan %T","messagePattern":"cannot scan %T","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/uuid.go","lineNumber":88,"sourceCode":"}\n\n// Scan implements the [database/sql.Scanner] interface.\nfunc (dst *UUID) Scan(src any) error {\n\tif src == nil {\n\t\t*dst = UUID{}\n\t\treturn nil\n\t}\n\n\tif src, ok := src.(string); ok {\n\t\tbuf, err := parseUUID(src)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t\t*dst = UUID{Bytes: buf, Valid: true}\n\t\treturn nil\n\t}\n\n\treturn fmt.Errorf(\"cannot scan %T\", src)\n}\n\n// Value implements the [database/sql/driver.Valuer] interface.\nfunc (src UUID) Value() (driver.Value, error) {\n\tif !src.Valid {\n\t\treturn nil, nil\n\t}\n\n\treturn encodeUUID(src.Bytes), nil\n}\n\nfunc (src UUID) String() string {\n\tif !src.Valid {\n\t\treturn \"\"\n\t}\n\n\treturn encodeUUID(src.Bytes)\n}","sourceCodeStart":70,"sourceCodeEnd":106,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/uuid.go#L70-L106","documentation":"Thrown by UUID.Scan when database/sql delivers a value that is neither nil nor a string — the method only type-switches on string, so concrete types like []byte, int64, or time.Time fall through to this generic guard. The input at fault is the src value's Go type, not its contents.","triggerScenarios":"Thrown at pgtype/uuid.go:88 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Ensure the source column is UUID or text so the driver delivers a string","Convert the value to a string before calling Scan","Scan through pgx's native interface, which handles []byte sources, instead of database/sql"],"exampleFix":null,"handlingStrategy":"type-guard","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"}