Skip to content

[sansara#7679] Use generateId() instead of direct crypto.randomUUID()#83

Merged
Panthevm merged 1 commit into
masterfrom
fix/rest-upsert-header-randomuuid
May 20, 2026
Merged

[sansara#7679] Use generateId() instead of direct crypto.randomUUID()#83
Panthevm merged 1 commit into
masterfrom
fix/rest-upsert-header-randomuuid

Conversation

@Panthevm
Copy link
Copy Markdown
Collaborator

@Panthevm Panthevm commented May 20, 2026

Summary

Two call sites used `crypto.randomUUID()` directly, which throws `TypeError: crypto.randomUUID is not a function` in non-secure contexts (plain HTTP, not localhost):

  • `src/routes/rest.tsx:366` — REST console `upsertHeader` (the original case reported in the issue).
  • `src/components/DataLineage/sidebar.tsx:60` — `SkeletonRows` loading state.

Both are switched to the existing safe `generateId()` wrapper in `utils.ts`, which falls back to a `Math.random`-based UUIDv4 string when `crypto.randomUUID` is unavailable.

REST regression originally introduced by `57aa46ab` ("Reduce cognitive complexity across 8 files"), which re-introduced the direct call after `ab16111` had already removed all such usages.

Test plan

  • Open REST console over plain HTTP (e.g. `http:///u/rest`); add or paste a request that triggers `upsertHeader` — no console error, headers row appears.
  • Open DataLineage sidebar over plain HTTP while data is loading — skeleton rows render without error.
  • Same scenarios still work on HTTPS / localhost.
  • `pnpm typecheck` / `pnpm lint:fix` green.

Closes HealthSamurai/sansara#7679.

Two call sites used crypto.randomUUID() directly, which throws
TypeError in non-secure contexts (plain HTTP, not localhost):

- src/routes/rest.tsx:366 (REST console upsertHeader)
- src/components/DataLineage/sidebar.tsx:60 (DataLineage SkeletonRows)

The safe generateId() wrapper in utils.ts falls back to a Math.random
based UUIDv4 string when crypto.randomUUID is unavailable.

Closes HealthSamurai/sansara#7679
@Panthevm Panthevm force-pushed the fix/rest-upsert-header-randomuuid branch 2 times, most recently from 7614f94 to 00d0487 Compare May 20, 2026 15:12
@Panthevm Panthevm changed the title [sansara#7679] Use generateId() in REST console upsertHeader [sansara#7679] Use generateId() instead of direct crypto.randomUUID() May 20, 2026
@Panthevm Panthevm merged commit c1f3ed4 into master May 20, 2026
4 checks passed
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.

1 participant