fix(drizzle-seed): generate RFC 4122 compliant UUID v4 variant bits#5448
Open
isaackaara wants to merge 1 commit intodrizzle-team:mainfrom
Open
fix(drizzle-seed): generate RFC 4122 compliant UUID v4 variant bits#5448isaackaara wants to merge 1 commit intodrizzle-team:mainfrom
isaackaara wants to merge 1 commit intodrizzle-team:mainfrom
Conversation
The UUID v4 generator was not setting the variant bits correctly.
RFC 4122 requires the first nibble of the 4th group (clock_seq_hi)
to be restricted to [8, 9, a, b] (binary 10xx), but the generator
was producing any hex digit in that position.
Example of previously invalid output:
6aa65a86-1248-4dcf-e3ec-304ba1343ca5
^ should be 8, 9, a, or b
This fixes the template to constrain the variant nibble to the
allowed values while keeping the rest of the UUID generation
unchanged.
Fixes drizzle-team#5402
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The UUID v4 generator in drizzle-seed was not setting the variant bits correctly. RFC 4122 requires the first nibble of the 4th group (
clock_seq_hi) to be restricted to[8, 9, a, b](binary10xx), but the generator was producing any hex digit in that position.Example of previously invalid output:
Fix:
The UUID template now uses a separate
Vplaceholder for the variant position, which is randomly selected from[8, 9, a, b]instead of the full hex range. The version nibble (4) was already correctly hardcoded.This ensures all generated UUIDs pass validation by libraries like
uuid'svalidate()and PostgreSQL's strictuuidtype.Fixes #5402