Skip to content

Commit

Permalink
communities: prevent errors in type field
Browse files Browse the repository at this point in the history
type attribute now checks if the value passed is a dict to prevent errors from happening before the value is validated. Now returns a normal validation error if the wrong type of value is passed.
  • Loading branch information
nico authored and slint committed Jun 8, 2022
1 parent 5f46f45 commit 9a1e85a
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions invenio_communities/communities/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,9 +88,11 @@ def clean(self, data, **kwargs):
Why: We want to allow the output of a Schema dump, to be a valid input
to a Schema load without causing strange issues.
"""
for name, field in self.fields.items():
if field.dump_only:
data.pop(name, None)
value_is_dict = isinstance(data, dict)
if value_is_dict:
for name, field in self.fields.items():
if field.dump_only:
data.pop(name, None)
return data


Expand Down

0 comments on commit 9a1e85a

Please sign in to comment.