Skip to content

Commit

Permalink
fix: Gracefully Handle Invalid Message Data
Browse files Browse the repository at this point in the history
  • Loading branch information
BrandonStalnaker committed Aug 30, 2021
1 parent 953f063 commit b618e5b
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions mParticle-Apple-SDK/Utils/MPMessageBuilder.mm
Original file line number Diff line number Diff line change
Expand Up @@ -382,6 +382,16 @@ - (MPMessage *)build {
messageDictionary[kMPMessageIdKey] = uuid ? uuid : [[NSUUID UUID] UUIDString];

NSNumber *userId = _session.userId.integerValue ? _session.userId : [MPPersistenceController mpId];
for (NSString *key in messageDictionary) {
if ([messageDictionary[key] isKindOfClass:[NSNumber class]]) {
NSNumber *value = (NSNumber *)messageDictionary[key];
if(value.doubleValue == INFINITY) {
MPILogVerbose(@"Invalid Message Data for key: %@", key);
MPILogVerbose(@"Value should not be infinite. Removing value from message data");
messageDictionary[key] = nil;
}
}
}

message = [[MPMessage alloc] initWithSession:_session
messageType:_messageType
Expand Down

0 comments on commit b618e5b

Please sign in to comment.