Skip to content

Commit 2473865

Browse files
author
Boris Pleshakov
committed
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 2473865

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

rest_framework_json_api/parsers.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -118,6 +118,8 @@ def parse(self, stream, media_type=None, parser_context=None):
118118

119119
# Check for inconsistencies
120120
if request.method in ('PUT', 'POST', 'PATCH'):
121+
if not isinstance(data, dict):
122+
raise ParseError('Received data is not a valid JSONAPI Resource Identifier Object')
121123
resource_name = utils.get_resource_name(
122124
parser_context, expand_polymorphic_types=True)
123125
if isinstance(resource_name, str):

0 commit comments

Comments
 (0)