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

ValueError: dictionary update sequence element #0 has length 1; 2 is required #746

Closed
braco opened this issue Nov 6, 2018 · 3 comments
Closed

Comments

@braco
Copy link

braco commented Nov 6, 2018

Getting a mysterious error with OpenAPI spec and connexion 2.0, will post here when I figure it out

* Running on http://0.0.0.0:8080/ (Press CTRL+C to quit)
[2018-11-05 23:51:32,803] ERROR in app: Exception on /path [GET]
Traceback (most recent call last):
  File "/project/lib/python3.6/site-packages/flask/app.py", line 2292, in wsgi_app
    response = self.full_dispatch_request()
  File "/project/lib/python3.6/site-packages/flask/app.py", line 1815, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/project/lib/python3.6/site-packages/flask/app.py", line 1718, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/project/lib/python3.6/site-packages/flask/_compat.py", line 35, in reraise
    raise value
  File "/project/lib/python3.6/site-packages/flask/app.py", line 1813, in full_dispatch_request
    rv = self.dispatch_request()
  File "/project/lib/python3.6/site-packages/flask/app.py", line 1799, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/project/lib/python3.6/site-packages/connexion/decorators/decorator.py", line 73, in wrapper
    response = function(request)
  File "/project/lib/python3.6/site-packages/connexion/decorators/uri_parsing.py", line 132, in wrapper
    response = function(request)
  File "/project/lib/python3.6/site-packages/connexion/decorators/validation.py", line 339, in wrapper
    return function(request)
  File "/project/lib/python3.6/site-packages/connexion/decorators/decorator.py", line 44, in wrapper
    response = function(request)
  File "/project/lib/python3.6/site-packages/connexion/decorators/parameter.py", line 108, in wrapper
    request.files, arguments, has_kwargs, sanitize)
  File "/project/lib/python3.6/site-packages/connexion/operations/abstract.py", line 268, in get_arguments
    has_kwargs, sanitize))
  File "/project/lib/python3.6/site-packages/connexion/operations/openapi.py", line 284, in _get_query_arguments
    arguments, has_kwargs, sanitize)
  File "/project/lib/python3.6/site-packages/connexion/operations/abstract.py", line 194, in _query_args_helper
    res[key] = self._get_val_from_param(value, query_defn)
  File "/project/lib/python3.6/site-packages/connexion/operations/openapi.py", line 295, in _get_val_from_param
    return make_type(value, query_schema["type"])
  File "/project/lib/python3.6/site-packages/connexion/utils.py", line 46, in make_type
    return type_func(value)
ValueError: dictionary update sequence element #0 has length 1; 2 is required
127.0.0.1 - - [05/Nov/2018 23:51:32] "GET /path?foo=bar HTTP/1.1" 500 -
@braco
Copy link
Author

braco commented Nov 6, 2018

In my OpenAPI spec, I changed this

    Geo:
      description: A Geolocation object
      type: object
      properties:
        latitude:
          type: integer
          example: 40.742306
        longitude:
          type: integer
          example: -74.003494

to this

    Geo:
      description: A Geolocation object
      type: array
      items:
        type: number
        format: double
      example: 40.742306,-74.003494

and that seems to fix the problem

@dtkav
Copy link
Collaborator

dtkav commented Nov 6, 2018

It would help me a lot if you could post an entire working spec so I can reproduce the issue.

@prabhu
Copy link

prabhu commented Feb 11, 2019

Hi,

This bug is due to the following line failing since the input is string instead of dict.

https://github.com/zalando/connexion/blob/master/connexion/operations/openapi.py#L268

Will you be able to fix this by converting the string to dict?

Thanks in advance!

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

No branches or pull requests

4 participants