Open dfed opened 2 years ago
Any solution ?
@ankittlp we ended up implementing data validation prior to calling into Segment to help find invalid data issues in our app. This issue is tracking adding that data validation to the Segment API.
@ankittlp we ended up implementing data validation prior to calling into Segment to help find invalid data issues in our app. This issue is tracking adding that data validation to the Segment API.
I am seeing this https://github.com/segmentio/analytics-ios/issues/1043 which brings me to the same function of deepCopy. Not sure if any invalid data is passed. As this is working fine on the prior iOS version < iOS 16.
Interesting! Though that issue doesn't seem directly related to this one.
This repo does a good job of transforming Dictionary types from non-JSON-compatible types to JSON-compatible types prior to sending analytics dictionaries to your backend via the serializableDeepCopy method.
However, if an infinite Double or Float value (created by dividing a Double or Float by zero) slips through the
serializableDeepCopy
method. The result of sending an infinite value is that this repo crashes with the errorSIGABRT (#0): Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid number value (infinite) in JSON write'
. Worse yet, this crash happens on Segment's own queue, making it difficult for teams to find the source of the corrupted log. Here's a screen grab from the stack trace showing Segment on its own queue:Ideally, this repo would detect an Infinite value as part of
-[NSDictionary serializableDeepCopy:]
and either crash (since this method is called synchronously from-[SEGAnalytics track:properties:options:]
, crashing here would yield a stack trace can help identify the source of the bad log) or remove/modify the infinite value.Let me know which approach seems reasonable to you – I'd be happy to create a PR with a fix here.