Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[version 2.20.0] TypeError: 'NoneType' object is not subscriptable #1342

sirkonst opened this issue Aug 12, 2019 · 2 comments


Copy link

commented Aug 12, 2019

After update from version 2.19.5 to 2.20.0 I got error for code like:

from marshmallow import Schema, fields, validates

class Bar(Schema):
    value = fields.String()

    @validates('value')  # <- issue here
    def validate_value(self, value):

class Foo(Schema):
    bar = fields.Nested(Bar)

sch = Foo()

    'bar': 'invalid',
Traceback (most recent call last):
  File "/_/", line 19, in <module>
    'bar': 'invalid',
  File "/_/env/lib/python3.7/site-packages/marshmallow/", line 628, in validate
    _, errors = self._do_load(data, many, partial=partial, postprocess=False)
  File "/_/env/lib/python3.7/site-packages/marshmallow/", line 670, in _do_load
  File "/_/env/lib/python3.7/site-packages/marshmallow/", line 292, in deserialize
    index=(index if index_errors else None)
  File "/_/env/lib/python3.7/site-packages/marshmallow/", line 65, in call_and_store
    value = getter_func(data)
  File "/_/env/lib/python3.7/site-packages/marshmallow/", line 285, in <lambda>
  File "/_/env/lib/python3.7/site-packages/marshmallow/", line 265, in deserialize
    output = self._deserialize(value, attr, data)
  File "/_/env/lib/python3.7/site-packages/marshmallow/", line 465, in _deserialize
    data, errors = self.schema.load(value)
  File "/_/env/lib/python3.7/site-packages/marshmallow/", line 588, in load
    result, errors = self._do_load(data, many, partial=partial, postprocess=True)
  File "/_/env/lib/python3.7/site-packages/marshmallow/", line 674, in _do_load
    self._invoke_field_validators(unmarshal, data=result, many=many)
  File "/_/env/lib/python3.7/site-packages/marshmallow/", line 894, in _invoke_field_validators
    value = data[field_obj.attribute or field_name]
TypeError: 'NoneType' object is not subscriptable

This comment has been minimized.

Copy link

commented Aug 12, 2019

Thanks for reporting. I was able to reproduce this on 2.20.0. This is likely a regression from #1323 . I don't have time to look into it now. Would appreciate a PR.


This comment has been minimized.

Copy link

commented Aug 13, 2019

This is fixed in 2.20.1.

@sloria sloria closed this Aug 13, 2019

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
2 participants
You can’t perform that action at this time.