fragment extension doc inadequately describes profile UUID generation #14168

Open
opened 2026-01-31 04:02:50 +00:00 by claunia · 0 comments
Owner

Originally created by @jeremyd2019 on GitHub (Jun 9, 2021).

In https://docs.microsoft.com/en-us/windows/terminal/json-fragment-extensions#how-to-determine-the-guid-of-an-existing-profile, it says:

To determine the GUID of the profile to be updated, use a Version 5 UUID generator with the following namespace GUID and name:

  • The namespace GUID: {2BDE4A90-D05F-401C-9492-E40884EAD1D8}
  • The name of the profile to be updated

As a sanity check, a profile called 'Ubuntu' will get the generated GUID: {2C4DE342-38B7-51CF-B940-2309A097F518}

If you go online and search for "version 5 UUID generator", you will find several webpages. None of these result in the {2C4DE342... UUID for "Ubuntu".

More research revealed #870 which says:

Canonical Form: Name of profile encoded in BOM-less UTF-8 BOM-less UTF-16LE

That's an apparently important piece of information that was missing from the fragment doc. OK, so we'll probably need some custom code after all

import uuid
uuid.uuid5(uuid.UUID("{2BDE4A90-D05F-401C-9492-E40884EAD1D8}"), "Ubuntu".encode("UTF-16LE"))

This works for python2 (but who uses that anymore?), but on python3 this gives

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python38\lib\uuid.py", line 787, in uuid5
    hash = sha1(namespace.bytes + bytes(name, "utf-8")).digest()
TypeError: encoding without a string argument

It seems that even Python hard-codes the fact that the name should be utf-8 encoded! Let's try a hack

import uuid
uuid.uuid5(uuid.UUID("{2BDE4A90-D05F-401C-9492-E40884EAD1D8}"), "Ubuntu".encode("UTF-16LE").decode("ASCII"))

That gives the expected answer.

So, to summarize, it seems like that doc should make it more clear that something unusual is going on in the UUID generation, rather than saying "just grab your nearest v5 UUID generator and plug these strings in".

Originally created by @jeremyd2019 on GitHub (Jun 9, 2021). <!-- Briefly describe which document needs to be corrected and why. --> In https://docs.microsoft.com/en-us/windows/terminal/json-fragment-extensions#how-to-determine-the-guid-of-an-existing-profile, it says: > To determine the GUID of the profile to be updated, use a Version 5 UUID generator with the following namespace GUID and name: > > * The namespace GUID: {2BDE4A90-D05F-401C-9492-E40884EAD1D8} > * The name of the profile to be updated > > As a sanity check, a profile called 'Ubuntu' will get the generated GUID: {2C4DE342-38B7-51CF-B940-2309A097F518} If you go online and search for "version 5 UUID generator", you will find several webpages. None of these result in the `{2C4DE342`... UUID for "Ubuntu". More research revealed #870 which says: > Canonical Form: Name of profile encoded in ~~BOM-less UTF-8~~ BOM-less UTF-16LE That's an apparently important piece of information that was missing from the fragment doc. OK, so we'll probably need some custom code after all ```python import uuid uuid.uuid5(uuid.UUID("{2BDE4A90-D05F-401C-9492-E40884EAD1D8}"), "Ubuntu".encode("UTF-16LE")) ``` This works for python2 (but who uses *that* anymore?), but on python3 this gives ``` Traceback (most recent call last): File "<stdin>", line 1, in <module> File "C:\Python38\lib\uuid.py", line 787, in uuid5 hash = sha1(namespace.bytes + bytes(name, "utf-8")).digest() TypeError: encoding without a string argument ``` It seems that even Python *hard-codes* the fact that the name should be utf-8 encoded! Let's try a hack ```python import uuid uuid.uuid5(uuid.UUID("{2BDE4A90-D05F-401C-9492-E40884EAD1D8}"), "Ubuntu".encode("UTF-16LE").decode("ASCII")) ``` That gives the expected answer. So, to summarize, it seems like that doc should make it more clear that something unusual is going on in the UUID generation, rather than saying "just grab your nearest v5 UUID generator and plug these strings in".
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#14168