`Field may not be null` when data_key parameter provided in Schema
It seems that if you provider the data_key parameter in your Schema, the field become required as a side-effect. Even if required=False and allow_none=True are added you will still get the Field may not be null error. Ideally I would like this field to still be optional even if the key is not available in the python dict that is passed to the schema.
Example: (Parts omitted in interest of brevity)
class AuthRepsSchema(Schema):
...
general_release_signer_info = fields.Mapping(data_key="generalReleaseSignerInfo")
...
auth_reps_V1 = self.auth_reps_v1_schema.load({"hello": "goodbye")
Will result in the marshmallow.exceptions.ValidationError: {'generalReleaseSignerInfo': ['Field may not be null.']} error.
I can't reproduce.
>>> import marshmallow as ma
>>> class AuthRepsSchema(ma.Schema):
... general_release_signer_info = ma.fields.Mapping(data_key="generalReleaseSignerInfo")
...
>>> s = AuthRepsSchema()
>>> s.load({"hello": "goodbye"})
marshmallow.exceptions.ValidationError: {'hello': ['Unknown field.']}
>>> s.load({})
{}
Can you please provide a minimal, complete and verifiable example?
I'm unable to reproduce as well now. I'll close this issue for now and reopen if I run into it again. Thanks for looking at it. I think I must be providing None somewhere in my code as the value for generalReleaseSignerInfo even though that is not my intention.