'Missing data for required field in Marshmallow 3.10.0

I am new to Marshmallow (3.10.0) and I am lost and need help trying to figure out what causes the following error:

AssertionError: ["Input Error - exten: ['Missing data for required field.']"]

The traceback of the error is the following:

Traceback (most recent call last):
  File "/root/wazo_virtualenv_python37/lib/python3.7/site-packages/nose/case.py", line 198, in runTest
    self.test(*self.arg)
  File "/root/wazo-confd/integration_tests/suite/helpers/wrappers.py", line 81, in decorated
    result = func(*new_args, **kwargs)
  File "/root/wazo-confd/integration_tests/suite/helpers/wrappers.py", line 81, in decorated
    result = func(*new_args, **kwargs)
  File "/root/wazo-confd/integration_tests/suite/base/test_call_filter_surrogate_user.py", line 216, in test_get_surrogates_callfilter_exten_when_disabled
    confd.extensions.features(feature['id']).put({'enabled': False}).assert_updated()
  File "/root/wazo-confd/integration_tests/suite/helpers/client.py", line 272, in assert_updated
    self.assert_status(204)
  File "/root/wazo-confd/integration_tests/suite/helpers/client.py", line 242, in assert_status
    assert_that(self.response.status_code, is_in(statuses), self.response.text)

So it seems that the test function test_get_surrogates_callfilter_exten_when_disabled is failing:

def test_get_surrogates_callfilter_exten_when_disabled(call_filter, user):
    response = confd.extensions.features.get(search="bsfilter")
    feature = response.items[0]
  ---> (line 216 in traceback):  confd.extensions.features(feature['id']).put({'enabled': False}).assert_updated()

    with a.call_filter_surrogate_user(call_filter, user):
        response = confd.callfilters(call_filter['id']).get()

        assert_that(
            response.item,
            has_entries(
                surrogates=has_entries(
                    users=contains(has_entries(exten=None, uuid=user['uuid']))
                )
            ),
        )

    confd.extensions.features(feature['id']).put(
        {'enabled': feature['enabled']}
    ).assert_updated()

the feature_extension schema is defined as the following:

class ExtensionFeatureSchema(BaseSchema):
    id = fields.Integer(dump_only=True)
    exten = fields.String(validate=Regexp(EXTEN_REGEX), required=True)
    context = fields.String(dump_only=True)
    feature = fields.String(attribute='typeval', dump_only=True)
    enabled = fields.Boolean()
    links = ListLink(Link('extensions_features'))

and the put function:

def put(self):
        form = self.schema().load(request.get_json())
        variables = [self.model(**option) for option in form]
        self.service.edit(self.section_name, variables)
        return '', 204

I have tried many solutions that I found online; but they did not fix the issue for me:

1 + pass partial=True to the load function: form = self.schema().load(request.get_json(), partial=True)

2 + remove required=True from the field definition; this made the above error go away but failed many other tests that I have.

I am currently out of ideas, so if anyone has an idea how to fix the issue.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source