Skip to content

Commit 2061c71

Browse files
authored
Create/update validation that "data" key is object
If you submit a list with one object, for example, drf_json_api will respond you with unobvious errors.
1 parent 2033bc5 commit 2061c71

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

rest_framework_json_api/parsers.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ def parse(self, stream, media_type=None, parser_context=None):
9494

9595
data = result.get('data')
9696
view = parser_context['view']
97+
98+
if not isinstance(data, dict):
99+
raise ParseError('Received data is not a valid JSONAPI Resource Identifier Object')
97100

98101
from rest_framework_json_api.views import RelationshipView
99102
if isinstance(view, RelationshipView):

0 commit comments

Comments
 (0)