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

Regression: Allow unknown causes dictionary validation to fail with a ``KeyError`` #302

Closed
daviskirk opened this Issue Mar 23, 2017 · 1 comment

Comments

Projects
None yet
2 participants
@daviskirk
Copy link
Contributor

daviskirk commented Mar 23, 2017

Used Cerberus version / latest commit: 1.1


Use-case abstract

Validating a dictionary with allow_unknown set to True


Support request / Bug report

This might be a regression, since testing this on 1.0.1 works fine:

v = cerberus.Validator({'a': {'type': 'dict', 'allow_unknown': True}})
v.validate({'a': {}})

Errors out with the exception:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "./lib/python3.5/site-packages/cerberus/validator.py", line 795, in validate
    self.__normalize_mapping(self.document, self.schema)
  File "./lib/python3.5/site-packages/cerberus/validator.py", line 549, in __normalize_mapping
    self.__normalize_containers(mapping, schema)
  File "./lib/python3.5/site-packages/cerberus/validator.py", line 607, in __normalize_containers
    field, mapping, schema)
  File "./lib/python3.5/site-packages/cerberus/validator.py", line 653, in __normalize_mapping_per_schema
    schema=schema[field]['schema'],
KeyError: 'schema'

The example without the 'allow_unknown' key or with an invalid type work without error:

v = cerberus.Validator({'a': {'type': 'dict'}})
v.validate({'a': {}}) # True
v = cerberus.Validator({'a': {'type': 'dict', 'allow_unknown': True}})
v.validate({})  # True
v.validate({'a': 4})  # False

@daviskirk daviskirk changed the title Regression: Allow unknown causes dictionary validator to fail Regression: Allow unknown causes dictionary validation to fail with a ``KeyError`` Mar 23, 2017

funkyfuture added a commit to funkyfuture/cerberus that referenced this issue Mar 24, 2017

@nicolaiarocci nicolaiarocci added the bug label Mar 25, 2017

@nicolaiarocci nicolaiarocci added this to the 1.2 milestone Mar 25, 2017

@nicolaiarocci

This comment has been minimized.

Copy link
Member

nicolaiarocci commented Mar 25, 2017

Thanks. Should be fixed now.

funkyfuture added a commit to funkyfuture/cerberus that referenced this issue Apr 18, 2017

funkyfuture added a commit to funkyfuture/cerberus that referenced this issue Apr 18, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment