WordPress-iOS icon indicating copy to clipboard operation
WordPress-iOS copied to clipboard

Crash in in WPKit when response is empty or invalid

Open kean opened this issue 2 years ago • 5 comments

Screenshot 2023-08-03 at 5 25 34 PM

In this case, the issue is a force cast from id to NSDictionary *.

kean avatar Aug 03 '23 21:08 kean

The same crash happens in:

- (void)getAllAuthorsWithRemoteUsers:(NSMutableArray <RemoteUser *>*)remoteUsers
                              offset:(NSNumber *)offset
                             success:(UsersHandler)success
                             failure:(void (^)(NSError *error))failure

kean avatar Aug 03 '23 21:08 kean

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.

kean avatar Aug 03 '23 21:08 kean

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.

kean avatar Aug 04 '23 13:08 kean

Sentry issue: JETPACK-IOS-178A

sentry[bot] avatar Dec 26 '23 15:12 sentry[bot]

Thanks for reporting! 👍

dangermattic avatar Sep 12 '24 18:09 dangermattic

Closing as wontfix because:

  1. We're replacing WPKit anyway
  2. The issue is no longer present in Sentry, so it may not be relevant anymore.

jkmassel avatar Apr 16 '25 02:04 jkmassel