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

improper Invalid.asdict behavior when raising an exception for a subnode #182

Open
mmerickel opened this issue Aug 9, 2014 · 0 comments

Comments

@mmerickel
Copy link
Member

def MyMappingValidator(node, value):
    raise colander.Invalid(node['foo'], 'value must be less than 50')

schema = colander.SchemaNode(
    colander.Sequence(),
    colander.SchemaNode(
        colander.Mapping(),
        colander.SchemaNode(colander.Integer(), name='foo'),
        validator=MyMappingValidator,
    ),
)

schema.deserialize([{'foo': 100}])

Results in the following traceback:

Traceback (most recent call last):
  File "<console>", line 1, in <module>
  File "/Users/michael/work/scratch/eggs/colander-1.0b1-py2.7.egg/colander/__init__.py", line 1917, in deserialize
    appstruct = self.typ.deserialize(self, cstruct)
  File "/Users/michael/scratch/eggs/colander-1.0b1-py2.7.egg/colander/__init__.py", line 988, in deserialize
    return self._impl(node, cstruct, callback, accept_scalar)
  File "/Users/michael/scratch/eggs/colander-1.0b1-py2.7.egg/colander/__init__.py", line 930, in _impl
    raise error
Invalid: {'0': 'value must be less than 50'}

Whereas if I put the validator on the node itself, the error message path properly indicates {'0.foo': 'value must be less than 50'}. Please ignore the simplicity of the example, the actual use case is for a validator that checks the subnodes based on other subnodes and the error messages do not come out correct right now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant