fix: prevent crash when transactionId is nil in transactionBegin #8715
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.
Fix crash when transactionId is nil in transactionBegin
Description
This PR fixes a critical crash in the iOS Firestore transaction module where the app would crash with
com.google.firebase.firestore.transaction
whentransactionId
isnil
. The crash occurs at line 156 inRNFBFirestoreTransactionModule.m
when attempting to use anil
key in anNSMutableDictionary
.Root Cause
transactionId
parameter can benil
in certain edge cases[transactionId stringValue]
on anil
NSNumber returnsnil
nil
as a key inNSMutableDictionary
causes a crash insetObject:forKeyedSubscript:
Solution
transactionId
isnil
and return early with loggingtransactionId
is invalidRelated issues
Fixes crash in
com.google.firebase.firestore.transaction
at line 156Release Summary
transactionId
isnil
in Firestore transactionsChecklist
Android
iOS
Other
(macOS, web)e2e
tests added or updated inpackages/**/e2e
jest
tests added or updated inpackages/**/__tests__
Test Plan
Before Fix
com.google.firebase.firestore.transaction
whentransactionId
isnil
RNFBFirestoreTransactionModule.m
After Fix
transactionId
isnil
"Error: transactionId is nil in transactionBegin"
FIRFirestoreErrorCodeInvalidArgument
error instead of crashingTest Cases
Code Changes
Think
react-native-firebase
is great? Please consider supporting the project with any of the below:React Native Firebase
andInvertase
on Twitter