Open DavidCain opened 8 years ago
What about this one?
@mattupstate, any input on this one? It closes a pretty easy mechanism for invoking 500's.
This one is basically the same as #70
@dequis it's similar, but actually catches errors not handled by #70. If you were to pass a string or array with a valid JSON mimetype, request.get_json()
will return something truthy. Then, the later call to data.get
would raise an AttributeError
, as neither strings nor lists implement a get
method.
That said, if I'd seen #70, I probably would have just left this as a comment instead of making a new PR.
When the request is not JSON (and the
force
flag is False), Flask'sget_json()
will returnNone
.If somebody POSTs to
/auth
with a non-JSON mimetype, the server will 500 with'NoneType' object has no attribute 'get'
.This fixes this behavior in the default
auth_request_handler
.