Bug in checkpoint id generation when converting UUID v1 to UUID v6. #41

Closed
opened 2026-02-15 17:06:01 -05:00 by yindo · 3 comments
Owner

Originally created by @chentschel on GitHub (Jun 27, 2024).

When the graph is generating a UUID v6 from the starting point the generated id looks like : 6fbb4270-3461-11ef-undefineda0-a9b17340a0aa.

Note the 'undefined' in the UUID generated.

This happens because the code used to generate the id is called with a negative number. (-1) when the graph does not have previous checkpoints.

UUID v1 to generate the ID here: https://github.com/langchain-ai/langgraphjs/blob/main/langgraph/src/checkpoint/id.ts#L30

After the v1 generation, there is a conversion to a UUID v6. It be easy to solve if the use uuid v6, from start. A proposed code bellow.

function uuid6(clockseq: number) {
  // using uuid pkg
  const node = crypto.getRandomValues(new Uint8Array(6));

  return  v6({ node, clockseq });
}

@nfcampos ?

Originally created by @chentschel on GitHub (Jun 27, 2024). When the graph is generating a UUID v6 from the starting point the generated id looks like : `6fbb4270-3461-11ef-undefineda0-a9b17340a0aa`. Note the 'undefined' in the UUID generated. This happens because the code used to generate the `id` is called with a negative number. (-1) when the graph does not have previous checkpoints. UUID v1 to generate the ID here: https://github.com/langchain-ai/langgraphjs/blob/main/langgraph/src/checkpoint/id.ts#L30 After the v1 generation, there is a conversion to a UUID v6. It be easy to solve if the use uuid v6, from start. A proposed code bellow. ``` function uuid6(clockseq: number) { // using uuid pkg const node = crypto.getRandomValues(new Uint8Array(6)); return v6({ node, clockseq }); } ``` @nfcampos ?
yindo closed this issue 2026-02-15 17:06:01 -05:00
Author
Owner

@nfcampos commented on GitHub (Jun 27, 2024):

how do we know v6 function doesn't have the same issue?
\

@nfcampos commented on GitHub (Jun 27, 2024): how do we know `v6` function doesn't have the same issue? \
Author
Owner

@chentschel commented on GitHub (Jun 27, 2024):

I tried in a separate script.

Also preferably , it would be good to use v7 instead of v6 . Is that ok
with you?

https://www.ietf.org/archive/id/draft-peabody-dispatch-new-uuid-format-04.html#name-uuid-version-7

CH

On Thu, 27 Jun 2024 at 8:17 PM Nuno Campos @.***> wrote:

how do we know v6 function doesn't have the same issue?
\


Reply to this email directly, view it on GitHub
https://github.com/langchain-ai/langgraphjs/issues/234#issuecomment-2195137104,
or unsubscribe
https://github.com/notifications/unsubscribe-auth/AACN566AAPODCSD26EZBMD3ZJQ3JPAVCNFSM6AAAAABJ7O6PSSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJVGEZTOMJQGQ
.
You are receiving this because you authored the thread.Message ID:
@.***>

@chentschel commented on GitHub (Jun 27, 2024): I tried in a separate script. Also preferably , it would be good to use v7 instead of v6 . Is that ok with you? https://www.ietf.org/archive/id/draft-peabody-dispatch-new-uuid-format-04.html#name-uuid-version-7 CH On Thu, 27 Jun 2024 at 8:17 PM Nuno Campos ***@***.***> wrote: > how do we know v6 function doesn't have the same issue? > \ > > — > Reply to this email directly, view it on GitHub > <https://github.com/langchain-ai/langgraphjs/issues/234#issuecomment-2195137104>, > or unsubscribe > <https://github.com/notifications/unsubscribe-auth/AACN566AAPODCSD26EZBMD3ZJQ3JPAVCNFSM6AAAAABJ7O6PSSVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMZDCOJVGEZTOMJQGQ> > . > You are receiving this because you authored the thread.Message ID: > ***@***.***> >
Author
Owner

@nfcampos commented on GitHub (Jun 27, 2024):

Thanks I'm going to merge the PR linked above. We use v6 as it supports a clock seq field, which we use to ensure checkpoint ids monodically increase with step number

@nfcampos commented on GitHub (Jun 27, 2024): Thanks I'm going to merge the PR linked above. We use v6 as it supports a clock seq field, which we use to ensure checkpoint ids monodically increase with step number
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: langchain-ai/langgraphjs#41