google / uuid

Go package for UUIDs based on RFC 4122 and DCE 1.1: Authentication and Security Services.
BSD 3-Clause "New" or "Revised" License
5.24k stars 363 forks source link

panic: uuid: Parse(): invalid UUID length: 0 #114

Closed ahloul closed 1 month ago

ahloul commented 1 year ago

I got this issue panic: uuid: Parse(): invalid UUID length: 0

toothsy commented 1 year ago

could you elaborate on how to replicate the panic?

jensilo commented 1 month ago

I guess, I know: uuid.MustParse. https://github.com/google/uuid/blob/0f11ee6918f41a04c201eceeadf612a377bc7fbc/uuid.go#L169

@ahloul use uuid.MustParse very wisely as it panics if the provided uuid.UUID is not parsable. Otherwise, use uuid.Parse and it returns an error if the provided string can't be parsed as UUID.

bormanp commented 1 month ago

As mentioned, this is the correct behavior of MustParse. Normally MustParse is used during initialization with fixed strings.