Closed likeuntomurphy closed 7 years ago
Thank you for the report, @likeuntomurphy. We’ll have to look into this, as I’m not sure offhand.
I think the simple solution here is to just fall through if the response type was json, but parsing it failed, or indeed, if it's empty.
I've sent a PR at https://github.com/bugsnag/bugsnag-symfony/pull/33 to address this. Hopefully this'll fix your problem. :)
The bundle throws a fatal error when
SymfonyRequest::getData()
is called, theContent-Type
of the request isapplication/json
and the request body is empty. In this case, the first operand in$this->getInput() + $this->request->query->all();
is not an array.That is the case that first affected me, but I realized the same will occur if the request body is a scalar value that
json_decode
will actually decode (true
,1
,"string"
, etc.). I know people still debate whether these are actually valid JSON — but the bigger issue here is that the bundle is throwing an uncatchable error.Further, our app is a RESTful API that accepts JSON. If it is invalid, we throw an exception with a message indicating the JSON is invalid. In the event that we actually wanted to capture that exception in Bugsnag, the subsequent
json_decode
would return false and trigger the fatal error before the report could be sent.Locally, I have modified the
SymfonyRequest
file to cast the output of json_decode to an array to avoid the fatal error. I did not make a pull request, because I was also curious about why JSON content is submitted to Bugsnag as if it were posted as form data — in the latter example, how would we see the invalid JSON string that was sent as the body? I honestly don’t know if Bugsnag is set up to accept the raw body at all, but I thought I’d raise the question.Thanks!