City-of-Bloomington / open311-ios

GeoReporter iOS source code. Native iOS smartphone client app for Open311 API civic issue reporting.
http://open311.org
Other
23 stars 22 forks source link

Crash when receiving invalid JSON response #215

Open inghamn opened 10 years ago

inghamn commented 10 years ago

For various reasons, an Open311 server may spit out invalid JSON in the response. Right now the app just crashes when this happens. We need to do error checking on the response and handle it in a nicer way.

inghamn commented 10 years ago

The Cocoa errors 3840 is coming from uReport spitting out an HTML error message in the JSON response. I'll need to also make sure uReport only spits out JSON errors.

If I POST to it using Open311 Generic POST (Content-Type: application/x-www-form-urlencoded; charset=utf-8\r\n \r\n api_key=XXXX=&jurisdiction_id=matthewncockburn.com&first_name=Matthew&last_name=Cockburn&&service_code=1&lat=55.5&long=-2.55&\r\n attribute[WHISPAWN]=123456&attribute[WHISDORN]=COISL001) I get:

\n\n\n\n\n\n\n\n\n\n\n

( ! ) Catchable fatal error: Argument 1 passed to Ticket::setAssignedPerson() must be an instance of Person, null given, called in /var/www/sites/crm/models/Ticket.php on line 125 and defined in /var/www/sites/crm/models/Ticket.php on line 209
Call Stack
#TimeMemoryFunctionLocation
10.0003262472{main}( )../index.php:0
20.01791719808Open311Controller->requests( )../index.php:68
30.34443373472Ticket->handleAdd( $post = array ('client_id' => NULL, 'contactMethod_id' => NULL, 'category_id' => '1', 'latitude' => '55.5', 'longitude' => '-2.55', 'customFields' => array ('WHISDORN' => 'COISL001'), 'reportedByPerson_id' => '9') )../Open311Controller.php:98
40.34663489960Ticket->save( )../Ticket.php:576
50.34663490304ActiveRecord->save( )../Ticket.php:144
60.34663490864Ticket->validate( )../ActiveRecord.php:21
70.34773570456Ticket->setAssignedPerson( $o = NULL )../Ticket.php:125