{"action":"opened","issue":{"url":"https://api.github.com/repos/django-json-api/django-rest-framework-json-api/issues/218","repository_url":"https://api.github.com/repos/django-json-api/django-rest-framework-json-api","labels_url":"https://api.github.com/repos/django-json-api/django-rest-framework-json-api/issues/218/labels{/name}","comments_url":"https://api.github.com/repos/django-json-api/django-rest-framework-json-api/issues/218/comments","events_url":"https://api.github.com/repos/django-json-api/django-rest-framework-json-api/issues/218/events","html_url":"https://github.com/django-json-api/django-rest-framework-json-api/issues/218","id":144340516,"number":218,"title":"Missing `errors` in error response","user":{"login":"joeyespo","id":634573,"avatar_url":"https://avatars.githubusercontent.com/u/634573?v=3","gravatar_id":"","url":"https://api.github.com/users/joeyespo","html_url":"https://github.com/joeyespo","followers_url":"https://api.github.com/users/joeyespo/followers","following_url":"https://api.github.com/users/joeyespo/following{/other_user}","gists_url":"https://api.github.com/users/joeyespo/gists{/gist_id}","starred_url":"https://api.github.com/users/joeyespo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joeyespo/subscriptions","organizations_url":"https://api.github.com/users/joeyespo/orgs","repos_url":"https://api.github.com/users/joeyespo/repos","events_url":"https://api.github.com/users/joeyespo/events{/privacy}","received_events_url":"https://api.github.com/users/joeyespo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":0,"created_at":"2016-03-29T17:56:36Z","updated_at":"2016-03-29T17:56:36Z","closed_at":null,"body":"The 400-level errors are responding with a JSON array containing error objects, but the JSON API spec [requires](http://jsonapi.org/format/#document-top-level) a top-level `error` field.\r\n\r\n##### To reproduce\r\n\r\n1. Use `serializer.is_valid(raise_exception=True)` in an API view\r\n2. Send invalid JSON from the client to *any* API endpoint\r\n\r\n    Example:\r\n    ```js\r\n    ajax({\r\n      url: '/my/api',\r\n      contentType: 'application/vnd.api+json',\r\n      type: 'POST',\r\n      data: 'not JSON'\r\n    });\r\n    ```\r\n\r\n    Expected response:\r\n    ```json\r\n    {\r\n      \"errors\": [\r\n        {\r\n          \"status\": \"400\",\r\n          \"source\": {\"pointer\": \"/data\"},\r\n          \"detail\": \"JSON parse error - No JSON object could be decoded\"\r\n        }\r\n      ]\r\n    }\r\n    ```\r\n\r\n    Actual response:    \r\n    ```json\r\n      [\r\n        {\r\n          \"status\": \"400\",\r\n          \"source\": {\"pointer\": \"/data\"},\r\n          \"detail\": \"JSON parse error - No JSON object could be decoded\"\r\n        }\r\n      ]\r\n    ```\r\n\r\nIt seems like the exception handler is [properly setting the resource name](https://github.com/django-json-api/django-rest-framework-json-api/blob/v2.0.0-beta.2/rest_framework_json_api/exceptions.py#L72), which *should* be used [here](https://github.com/django-json-api/django-rest-framework-json-api/blob/v2.0.0-beta.2/rest_framework_json_api/renderers.py#L376-L405). The former gets called, but the latter does not. DRF seems to have taken over, responding with this project's `exception_handler` as-is.\r\n\r\n##### My requirements\r\n\r\n```\r\n...\r\nDjango==1.9.1\r\ndjangorestframework==3.3.3\r\ndjangorestframework-jsonapi==2.0.0-beta.2\r\n...\r\n```\r\n\r\n##### My config\r\n\r\n```py\r\nREST_FRAMEWORK = {\r\n    'DEFAULT_PERMISSION_CLASSES': (\r\n        'rest_framework.permissions.IsAuthenticated',\r\n    ),\r\n    'DEFAULT_AUTHENTICATION_CLASSES': (\r\n        'rest_framework.authentication.TokenAuthentication',\r\n        'rest_framework.authentication.BasicAuthentication',\r\n    ),\r\n    'DEFAULT_RENDERER_CLASSES': (\r\n        'rest_framework_json_api.renderers.JSONRenderer',\r\n    ),\r\n    'DEFAULT_PARSER_CLASSES': (\r\n        'rest_framework_json_api.parsers.JSONParser',\r\n        'rest_framework.parsers.FormParser',\r\n        'rest_framework.parsers.MultiPartParser',\r\n    ),\r\n    'EXCEPTION_HANDLER': 'rest_framework_json_api.exceptions.exception_handler',\r\n}\r\n```"}}