fix: replace crypto.randomUUID with universal generateId utility#3485
fix: replace crypto.randomUUID with universal generateId utility#3485MaxwellCalkin wants to merge 2 commits intosimstudioai:mainfrom
Conversation
…studioai#3393) Replace all direct crypto.randomUUID() calls with a generateId() helper that falls back to the uuid package when crypto.randomUUID is unavailable. crypto.randomUUID() is only available in secure contexts (HTTPS or localhost). When Sim is self-hosted via Docker and accessed over plain HTTP on a LAN, the call throws "crypto.randomUUID is not a function" and the page white-screens. Changes: - Add generateId() utility in lib/core/utils/id.ts that tries crypto.randomUUID() first, then falls back to uuid v4 (already a dependency) - Replace all 200+ crypto.randomUUID() calls across 117 files - Keep the existing layout.tsx polyfill as defense-in-depth for third-party code - Add mockGenerateId() to the testing package for test consistency > **AI Disclosure:** This PR was authored by an AI agent (Claude, Anthropic). > All code changes, analysis, and PR description were generated autonomously. > A human (Max Calkin, @MaxwellCalkin) provided the prompt and submitted this PR. Closes simstudioai#3393
PR SummaryMedium Risk Overview Replaces Written by Cursor Bugbot for commit 782e1d1. This will update automatically on new commits. Configure here. |
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
...orkflowId]/components/panel/components/deploy/components/deploy-modal/components/a2a/a2a.tsx
Outdated
Show resolved
Hide resolved
The automated crypto.randomUUID replacement incorrectly added a generateId import into a Python code example template literal, producing invalid Python in the deploy modal's A2A code snippet. AI Disclosure: This commit was authored by Claude Opus 4.6 (Anthropic), operated by Maxwell Calkin (@MaxwellCalkin).
Summary
Fixes #3393 — White screen / "Application error" when
crypto.randomUUIDis not available.crypto.randomUUID()is only available in secure contexts (HTTPS or localhost). When Sim is self-hosted via Docker and accessed over plain HTTP on a LAN (e.g.http://192.168.x.x:3000), the call throwsTypeError: crypto.randomUUID is not a functionand the page white-screens.Changes
generateId()utility (apps/sim/lib/core/utils/id.ts) — triescrypto.randomUUID()first, falls back touuidv4 (already a dependency inpackage.json)crypto.randomUUID()calls across 117 files withgenerateId()layout.tsxpolyfill as defense-in-depth for any third-party code that may callcrypto.randomUUIDdirectlymockGenerateId()to the testing package (packages/testing/src/mocks/uuid.mock.ts) for consistent test mockingWhy not just fix the polyfill?
The existing
layout.tsxpolyfill only runs client-side at browser runtime viadangerouslySetInnerHTML. It does not cover:crypto.randomUUIDmay also be unavailableuuidpackage is already installed and used in ~30 other files, so the fallback adds no new dependenciesTest plan