Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The .uuid property does not give the right UUID according to spec/valid.yml #15

Open
jamt9000 opened this issue Jun 29, 2024 · 1 comment

Comments

@jamt9000
Copy link

jamt9000 commented Jun 29, 2024

According to the spec, the typeid 00000000000000000000000000 should become an all-zero uuid:

Implementations SHOULD allow encoding/decoding of other UUID variants when the bits are provided by end users. This makes it possible for applications to encode other UUID variants like UUIDv1 or UUIDv4 at their discretion.

https://github.com/jetify-com/typeid/blob/3c625fbca835217be361e6ff16d3d4ec255470e6/spec/valid.yml#L28-L31

- name: nil
  typeid: "00000000000000000000000000"
  prefix: ""
  uuid: "00000000-0000-0000-0000-000000000000"

However, this implementation seems to be converting it to a uuid7 00000000-0000-7000-8000-000000000000

In [1]: from typeid import TypeID

In [2]: TypeID(suffix="00000000000000000000000000")
Out[2]: TypeID('00000000000000000000000000')

In [3]: TypeID(suffix="00000000000000000000000000").uuid
Out[3]: UUID('00000000-0000-7000-8000-000000000000')

Which means it is not roundtrip-safe when converting back to a typeid:

In [4]: TypeID.from_uuid(TypeID(suffix="00000000000000000000000000").uuid)
Out[4]: TypeID('0000000000e008000000000000')
@akhundMurad
Copy link
Owner

Hello, @jamt9000, thanks for reporting!
I will try to prepare a fix this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants