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

Serializer fails when array of types is in schema #1112

Kobzol opened this Issue Feb 14, 2018 · 1 comment


None yet
2 participants
Copy link

Kobzol commented Feb 14, 2018

When an array of types is used in a schema ('type': ['string', 'number']), the Eve serializer (the function serialize in will fail with the exception 'unhashable list'. This can be hard to find, because the serializer swallows exceptions and sometimes the request will go through OK, but sometimes it will fail because the serializer didn't serialize everything correctly.

Example (the exception is thrown with this schema at

    'val': {
        'type': 'dict',
        'schema': {
            'x': {
                'type': ['string', 'number'],
                'required': True
            'timestamp': {
                'type': 'datetime',
                'required': False

When I POST a new item to this schema, it will either insert it and return 201 or return 422 with the error "timestamp": "must be of datetime type". This depends on the order in which the serializer goes through the fields, which is non-deterministic. Either it serializes the datetime first, then it's ok, or it finds the constraint 'type': ['string', 'number'] which stops the serializer, the datetime stays unparsed and the request fails.

Is array of types supported by Eve? It is officially supported by Cerberus. I tried replacing it with 'anyof_type': ['string', 'number'], but that returns an error (no definitions validate).

Version: 0.8-dev from latest github master (commit sha 1d4a308)
Python version: happens both on 2.7 and 3.5

@nicolaiarocci nicolaiarocci added the bug label May 17, 2018

@nicolaiarocci nicolaiarocci added this to the 0.8.1 milestone May 17, 2018


This comment has been minimized.

Copy link

nicolaiarocci commented May 17, 2018

This should be fixed now. Thanks and sorry for the long wait.

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