fix(datastore): load react-native-get-random-values for uuid v11 on React Native#14842
Merged
Merged
Conversation
…eact Native uuid was bumped to ^11.1.1 (#14839) to address CVE-2026-41907. uuid v11's v4() throws when crypto.getRandomValues is unavailable, whereas uuid v3 fell back to Math.random(). On React Native crypto.getRandomValues is not present unless the react-native-get-random-values polyfill is loaded, so every DataStore.save() of a syncable model (which mints its primary key via uuid4()) now throws on RN. This loads the polyfill from within @aws-amplify/datastore via a platform-resolved side-effect module (loadGetRandomValues.native.ts on RN, a no-op on web/Node, selected automatically by Metro's .native resolution), mirroring the loadGetRandomValues mechanism already shipped on v6/main. RN consumers no longer need to add 'import "react-native-get-random-values"' themselves. react-native-get-random-values is declared as an optional peerDependency so package managers surface the install/pod requirement without affecting web/Node consumers.
|
ahmedhamouda78
approved these changes
Jun 12, 2026
bobbor
approved these changes
Jun 12, 2026
osama-rizk
added a commit
that referenced
this pull request
Jun 15, 2026
The previous v5 release published only ~6 of the package set before lerna aborted on a failed amazon-cognito-identity-js postpublish dist-tag hook, leaving aws-amplify@5.3.34, @aws-amplify/datastore@4.7.23 (RN uuid-v11 fix, \#14842), @aws-amplify/api, @aws-amplify/auth, datastore-storage-adapter, predictions, and pubsub unpublished on the stable-5 tag. This is a no-op comment touching every package so lerna --conventional-commits treats them all as changed and republishes the full v5 suite to stable-5 at a fresh consistent version. No functional code change.
osama-rizk
added a commit
that referenced
this pull request
Jun 15, 2026
…es) (#14843) The previous v5 release published only ~6 of the package set before lerna aborted on a failed amazon-cognito-identity-js postpublish dist-tag hook, leaving aws-amplify@5.3.34, @aws-amplify/datastore@4.7.23 (RN uuid-v11 fix, \#14842), @aws-amplify/api, @aws-amplify/auth, datastore-storage-adapter, predictions, and pubsub unpublished on the stable-5 tag. This is a no-op comment touching every package so lerna --conventional-commits treats them all as changed and republishes the full v5 suite to stable-5 at a fresh consistent version. No functional code change.
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.
Problem
After #14839 bumped
uuidto^11.1.1(to address CVE-2026-41907), the React Native DataStore E2E suite (integ_rn_ios_datastore_sqlite_adapter) started failing at runtime: everyDataStore.save()of a syncable model fails, so the in-app "Successfully created new user!" notification never appears and the SQLiteAdapter Detox suite cascades to all-red.Root cause
uuid4()—packages/datastore/src/datastore/datastore.ts(import { v4 as uuid4 } from 'uuid', used at thesave()draft producer).v4()fell back toMath.random()whencrypto.getRandomValueswas unavailable.v4()instead throwscrypto.getRandomValues() not supportedwhen it's missing.crypto.getRandomValuesdoes not exist unless thereact-native-get-random-valuespolyfill has been loaded. So on RN, uuid v11 throws on every model create.This is isolated to DataStore — the Storage/Geo RN Detox suites (which don't mint model ids via uuid) pass on the same release runs. CI timeline confirms the job was green on the release immediately before #14839 and red on #14839 and every run since.
Fix
Load the polyfill from within
@aws-amplify/datastorevia a platform-resolved side-effect module, so consumers don't have to import it themselves:loadGetRandomValues.ts— no-op (web/Node).loadGetRandomValues.native.ts—require('react-native-get-random-values'), selected automatically by Metro's.nativeresolution (same precedent asInMemoryStore.native.ts).datastore.tsmodule load, before anyuuid4()call.react-native-get-random-valuesdeclared as an optionalpeerDependencyso package managers surface the install/pod requirement without affecting web/Node.This mirrors the
loadGetRandomValuesmechanism already shipped on v6/main(packages/react-native+@aws-amplify/core'samplifyUuid/index.native.ts), adapted to v5 which has no@aws-amplify/react-nativepackage.Why no samples change
The
SQLiteAdaptersample already listsreact-native-get-random-valuesin itspackage.json(andPodfile.lock) — it simply never imported it. This PR makes the library load it, so the fix is verifiable without modifying the sample: merge this, re-run the failedinteg_rn_ios_datastore_sqlite_adapterjob, and it should pass on the unchanged sample.Test plan
E2E-Detox integ_rn_ios_datastore_sqlite_adapteragainst this branch — expect green with no sample changes.loadGetRandomValuesis a no-op; no new bundled dependency on the native module).Notes