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

VALIDATE_FILTERS setting doesn't work for filter on sub-document field #1123

Closed
lmoretto opened this Issue Mar 16, 2018 · 1 comment

Comments

Projects
None yet
2 participants
@lmoretto
Copy link
Contributor

lmoretto commented Mar 16, 2018

Activating the VALIDATE_FILTERS setting causes request with filters on sub-documents' fields to fail.

Steps to reproduce
Suppose you have a domain resource with the following schema:

'collection': {
    'schema': {
        'sub_documents': {
            'type': 'list',
            'schema': {
                'type': 'dict',
                'schema' : {
                    'foo': {'type': 'string'}
                    'bar': {'type': 'integer'}
                }
            }
        }
    }
}

Performing a request like:
http://<api_server>/collection?where={"sub_documents.bar": 5}
returns the following response:

{
    "_status": "ERR",
    "_error": {
        "code": 400,
        "message": "filter on '%s' is invalid"
    }
}

This seems to be caused in eve/utils.py at lines 403-406:

if config.VALIDATE_FILTERS:
    res_schema = config.DOMAIN[resource]['schema']
    if key not in res_schema:
        return "filter on '%s' is invalid"

In this scenario, key will be sub_documents.bar which is not a valid key in the res_schema dict (whereas sub_documents is).

@nicolaiarocci nicolaiarocci added the bug label Mar 16, 2018

@nicolaiarocci

This comment has been minimized.

Copy link
Member

nicolaiarocci commented Mar 16, 2018

Excellent. Looks like we're missing support for sub-document parsing here. Feel free to submit a PR if so inclined, I will gladly review it.

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.