Crash in in WPKit when response is empty or invalid
In this case, the issue is a force cast from id to NSDictionary *.
The same crash happens in:
- (void)getAllAuthorsWithRemoteUsers:(NSMutableArray <RemoteUser *>*)remoteUsers
offset:(NSNumber *)offset
success:(UsersHandler)success
failure:(void (^)(NSError *error))failure
An easy way to test it is by using Charles with a rewrite tool replacing all response bodies with empty data.
I'm setting the priority to High because it has the potential to bring the whole app down on launch.
Another crash happens in the requests that use the following pattern to decode the response in case it's a non-valid JSON object:
case .success(let responseObject):
do {
let data = try JSONSerialization.data(withJSONObject: responseObject, options: [])
let decoder = JSONDecoder.apiDecoder
2023-08-04 09:17:47.461864-0400 Jetpack[56105:4684154] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** +[NSJSONSerialization dataWithJSONObject:options:error:]: Invalid top-level type in JSON write'
For example, it happens, if the response is empty.
Sentry issue: JETPACK-IOS-178A
Thanks for reporting! 👍
Closing as wontfix because:
- We're replacing WPKit anyway
- The issue is no longer present in Sentry, so it may not be relevant anymore.