Skip to content

fix(lint): flag crypto.randomUUID() as non-deterministic code - #7325

Closed
rezamuliawijaya wants to merge 1 commit into
heygen-com:mainfrom
rezamuliawijaya:fix/lint-random-uuid
Closed

rezamuliawijaya wants to merge 1 commit into
heygen-com:mainfrom
rezamuliawijaya:fix/lint-random-uuid

Conversation

@rezamuliawijaya

Copy link
Copy Markdown

What

Adds crypto.randomUUID to the non_deterministic_code rule's pattern list in packages/lint/src/rules/core.ts, with a test in core.test.ts.

Why

The render shim seeds getRandomValues only (packages/producer/src/services/fileServer.ts), so crypto.randomUUID() stays random between renders and workers. A composition using it lints clean today while still producing a different UUID on every render — the same symptom Math.random and crypto.getRandomValues are already flagged for.

Related work

Fixes #7276

How

One pattern entry in the rule's pattern list, grouped with the sibling crypto.getRandomValues entry and carrying a comment explaining why it is non-deterministic even though the shim seeds entropy. The hint mirrors the existing randomness guidance (seeded PRNG), matching the assertion style of the neighboring test.

Test plan

  • Unit tests added/updated — new test detects crypto.randomUUID() in script content; bun test packages/lint/src/rules/core.test.ts passes 200/200
  • Pre-commit hooks pass (lint, format, tracked-artifacts, fallow, typecheck, commitlint)
  • Manual testing performed
  • Documentation updated (if applicable)

The render shim seeds getRandomValues only, so a composition calling
crypto.randomUUID() lints clean but still produces a different UUID on
every render and in every worker. Reproduce: compose a script that calls
crypto.randomUUID(), lint it — no non_deterministic_code finding appears
even though the value diverges across renders, the same symptom Math.random
and crypto.getRandomValues are flagged for.
@jrusso1020

Copy link
Copy Markdown
Collaborator

Thanks for contributing this fix. I reviewed the competing submissions and selected #7322, which includes the same runtime fix with a regression test that also pins its seeded-PRNG guidance. Closing this as a duplicate so the issue has one implementation to take through CI and merge: #7322. This is consolidation of overlapping work, not a rejection of your contribution.

@jrusso1020 jrusso1020 closed this Nov 7, 2026
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

Successfully merging this pull request may close these issues.

Lint: flag crypto.randomUUID() as non-deterministic

2 participants