Page MenuHomeDevCentral

Send a non JSON error to /gate/GitHub should fail sooner
Closed, ResolvedPublic

Description

A null reference exception occurs when we try to post a Phabricator payload to a GitHub gate.

I suggest to first fix the error, but then to also directly throw an exception is event is null or if the request doesn't contain a valid JSON payload (with a 400 http code?).

[2016-01-23 03:57:38] production.INFO: [Gate] New payload. {"service":"GitHub","door":"foo","delivery":null,"event":null} 
[2016-01-23 03:57:38] production.ERROR: exception 'ErrorException' with message 'Trying to get property of non-object' in var/wwwroot/default/app/Analyzers/GitHub/GitHubPayloadAnalyzer.php:91
Stack trace:
#0 /var/wwwroot/default/app/Analyzers/GitHub/GitHubPayloadAnalyzer.php(91): Illuminate\Foundation\Bootstrap\HandleExceptions->handleError(8, 'Trying to get p...', '/var/wwwroot/de...', 91, Array)
#1 /var/wwwroot/default/app/Analyzers/GitHub/GitHubPayloadAnalyzer.php(122): Nasqueron\Notifications\Analyzers\GitHub\GitHubPayloadAnalyzer->getRepository()
#2 /var/wwwroot/default/app/Listeners/AMQPEventListener.php(47): Nasqueron\Notifications\Analyzers\GitHub\GitHubPayloadAnalyzer->getGroup()
#3 /var/wwwroot/default/app/Listeners/AMQPEventListener.php(26): Nasqueron\Notifications\Listeners\AMQPEventListener::getGroup(Object(Nasqueron\Notifications\Events\GitHubPayloadEvent))  
#4 /var/wwwroot/default/app/Listeners/AMQPEventListener.php(67): Nasqueron\Notifications\Listeners\AMQPEventListener::getGitHubEventRoutingKey(Object(Nasqueron\Notifications\Events\GitHubPayloadEvent))  
#5 /var/wwwroot/default/app/Listeners/AMQPEventListener.php(57): Nasqueron\Notifications\Listeners\AMQPEventListener->sendRawPayload(Object(Nasqueron\Notifications\Events\GitHubPayloadEvent))
#6 [internal function]: Nasqueron\Notifications\Listeners\AMQPEventListener->onGitHubPayload(Object(Nasqueron\Notifications\Events\GitHubPayloadEvent))
#7 /var/wwwroot/default/bootstrap/cache/compiled.php(9831): call_user_func_array(Array, Array)
#8 [internal function]: Illuminate\Events\Dispatcher->Illuminate\Events\{closure}(Object(Nasqueron\Notifications\Events\GitHubPayloadEvent))
#9 /var/wwwroot/default/bootstrap/cache/compiled.php(9776): call_user_func_array(Object(Closure), Array)
#10 /var/wwwroot/default/bootstrap/cache/compiled.php(6118): Illuminate\Events\Dispatcher->fire(Object(Nasqueron\Notifications\Events\GitHubPayloadEvent))
#11 /var/wwwroot/default/app/Http/Controllers/Gate/GitHubGateController.php(158): Illuminate\Support\Facades\Facade::__callStatic('fire', Array)
#12 /var/wwwroot/default/app/Http/Controllers/Gate/GitHubGateController.php(158): Illuminate\Support\Facades\Event::fire(Object(Nasqueron\Notifications\Events\GitHubPayloadEvent))
#13 /var/wwwroot/default/app/Http/Controllers/Gate/GitHubGateController.php(82): Nasqueron\Notifications\Http\Controllers\Gate\GitHubGateController->onPayload()
#14 [internal function]: Nasqueron\Notifications\Http\Controllers\Gate\GitHubGateController->onPost('foo')

Event Timeline

Such request is now directly rejected by the controller with a 400 Bad request HTTP response.