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

Validating a Mapping that isn't a dict fails #299

Open
thanatos opened this issue Jul 26, 2017 · 0 comments
Open

Validating a Mapping that isn't a dict fails #299

thanatos opened this issue Jul 26, 2017 · 0 comments

Comments

@thanatos
Copy link

This is essentially the same issue as #125; it appears maybe this feature is now broken?

I, like #125, am attempting to validate an aiohttp request query arguments, which isn't a dict, but is a Mapping.

However, voluptuous requires a dict, as can be seen here; I see this in my stack trace:

Traceback (most recent call last):
  File "…/lib/python3.6/site-packages/voluptuous/schema_builder.py", line 221, in __call__
    return self._compiled([], data)
  File "…/lib/python3.6/site-packages/voluptuous/schema_builder.py", line 504, in validate_dict
    raise er.DictInvalid('expected a dictionary', path)
voluptuous.error.DictInvalid: expected a dictionary

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "…/lib/python3.6/site-packages/aiohttp/web_protocol.py", line 422, in start
    resp = yield from self._request_handler(request)
  File "…/lib/python3.6/site-packages/aiohttp/web.py", line 306, in _handle
    resp = yield from handler(request)
  File "…/__main__.py", line 32, in wrapper
    json_data = await func(*args, **kwargs)
  File "…/__main__.py", line 88, in foo
    validated_qargs = _SCHEMA(request.query)
  File "…/lib/python3.6/site-packages/voluptuous/schema_builder.py", line 225, in __call__
    raise er.MultipleInvalid([e])
voluptuous.error.MultipleInvalid: expected a dictionary

I think it's as simple as changing that dict to Mapping?

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