Skip to content

Commit

Permalink
don't crash on empty post with fieldsets
Browse files Browse the repository at this point in the history
  • Loading branch information
sheppard committed Jun 12, 2023
1 parent 7898de4 commit aab0284
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion rest/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -567,7 +567,7 @@ def to_virtual_fieldsets(self, data):
return data

def to_internal_value(self, data):
if not getattr(self.Meta, "wq_fieldsets", None):
if not data or not getattr(self.Meta, "wq_fieldsets", None):
return super().to_internal_value(data)

for name, conf in self.Meta.wq_fieldsets.items():
Expand Down
7 changes: 7 additions & 0 deletions tests/test_post.py
Original file line number Diff line number Diff line change
Expand Up @@ -266,3 +266,10 @@ def test_rest_virtual_fieldset(self):
self.assertEqual(
response.data, {"general": {"title": ["This field is required."]}}
)

def test_empty_post(self):
"""
Empty post should return 400, not 500
"""
response = self.client.post("/entities.json", data={})
self.assertTrue(status.is_client_error(response.status_code), response.data)

0 comments on commit aab0284

Please # to comment.