diff --git a/FirebaseABTesting/CHANGELOG.md b/FirebaseABTesting/CHANGELOG.md index c4d12585d75..413f0e41b19 100644 --- a/FirebaseABTesting/CHANGELOG.md +++ b/FirebaseABTesting/CHANGELOG.md @@ -1,3 +1,6 @@ +# Unreleased +- [fixed] Fix crash caused by empty experiment payload. + # 10.14.0 - [fixed] Fix crash caused by mutating array during iteration. (#11669) diff --git a/FirebaseABTesting/Sources/ABTConditionalUserPropertyController.m b/FirebaseABTesting/Sources/ABTConditionalUserPropertyController.m index 6f77f04efe0..e555826c508 100644 --- a/FirebaseABTesting/Sources/ABTConditionalUserPropertyController.m +++ b/FirebaseABTesting/Sources/ABTConditionalUserPropertyController.m @@ -87,6 +87,13 @@ - (void)setExperimentWithOrigin:(NSString *)origin return; } + if (payload.experimentId == nil) { + // When doing experiment test on devices, the payload could be empty. Returning here to prevent + // app crash. + FIRLogInfo(kFIRLoggerABTesting, @"I-ABT000020", @"Experiment Id in payload is empty."); + return; + } + if (maxNumOfExperiments <= experiments.count) { ABTExperimentPayloadExperimentOverflowPolicy overflowPolicy = [self overflowPolicyWithPayload:payload originalPolicy:policy];