{"record":{"id":"4520a31a15de01f7","repo":"jackc/pgx","slug":"cannot-parse-uuid-v","errorCode":null,"errorMessage":"cannot parse UUID %v","messagePattern":"cannot parse UUID (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pgtype/uuid.go","lineNumber":43,"sourceCode":"\t*b = v\n\treturn nil\n}\n\n// UUIDValue implements the [UUIDValuer] interface.\nfunc (b UUID) UUIDValue() (UUID, error) {\n\treturn b, nil\n}\n\n// parseUUID converts a string UUID in standard form to a byte array.\nfunc parseUUID(src string) (dst [16]byte, err error) {\n\tswitch len(src) {\n\tcase 36:\n\t\tsrc = src[0:8] + src[9:13] + src[14:18] + src[19:23] + src[24:]\n\tcase 32:\n\t\t// dashes already stripped, assume valid\n\tdefault:\n\t\t// assume invalid.\n\t\treturn dst, fmt.Errorf(\"cannot parse UUID %v\", src)\n\t}\n\n\tbuf, err := hex.DecodeString(src)\n\tif err != nil {\n\t\treturn dst, err\n\t}\n\n\tcopy(dst[:], buf)\n\treturn dst, err\n}\n\n// encodeUUID converts a uuid byte array to UUID standard string form.\nfunc encodeUUID(src [16]byte) string {\n\tvar buf [36]byte\n\n\thex.Encode(buf[0:8], src[:4])\n\tbuf[8] = '-'\n\thex.Encode(buf[9:13], src[4:6])","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/jackc/pgx/blob/ec1a0befd22592cffffdeeb0a50311b506372f4c/pgtype/uuid.go#L25-L61","documentation":"Thrown by parseUUID when the input string's length is neither 36 (standard hyphenated form) nor 32 (bare hexadecimal), so it cannot be a UUID before hex decoding is even attempted. It surfaces through Scan and UnmarshalJSON whenever the source string is malformed, truncated, or carries extra decoration such as a urn:uuid: prefix or braces.","triggerScenarios":"Thrown at pgtype/uuid.go:43 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Validate the string is 36 hyphenated or 32 hex characters before calling Scan or UnmarshalJSON","Strip decorations such as urn:uuid: prefixes or braces before parsing","Use google/uuid's Parse for lenient handling of variant UUID forms"],"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"}