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

Connexion hides real errors in endpoint handling module #218

Closed
tommyjcarpenter opened this issue Apr 30, 2016 · 2 comments
Closed

Connexion hides real errors in endpoint handling module #218

tommyjcarpenter opened this issue Apr 30, 2016 · 2 comments
Assignees

Comments

@tommyjcarpenter
Copy link

tommyjcarpenter commented Apr 30, 2016

Description

If you have an error in the module that handles an endpoint, Connexion bombs while importing the API, so you never see what the real error is. You have to drop into python and import the endpoint-handling module to see the real error. This makes debugging somewhat painful.

Expected bahaviour

If I drop into python, I see the real error in my module (in this case, a missing import):

Python 3.5.0 (default, Sep 23 2015, 04:41:38)
[GCC 4.2.1 Compatible Apple LLVM 7.0.0 (clang-700.0.72)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> from query_service.controllers import controller
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/tommy/Development/query_service/py/query_service/controllers/controller.py", line 1, in <module>
    import psycopg2
ImportError: No module named 'psycopg2'

Actual behaviour

Failed to add operation for GET /tenant/{vmname}
Traceback (most recent call last):
  File "py/query_service/rest_service.py", line 7, in <module>
    app.add_api('swagger.yaml', arguments={'title': 'Query Service'})
  File "/Users/tommy/.virtualenvs/aai/lib/python3.5/site-packages/connexion/app.py", line 146, in add_api
    debug=self.debug)
  File "/Users/tommy/.virtualenvs/aai/lib/python3.5/site-packages/connexion/api.py", line 132, in __init__
    self.add_paths()
  File "/Users/tommy/.virtualenvs/aai/lib/python3.5/site-packages/connexion/api.py", line 203, in add_paths
    six.reraise(*sys.exc_info())
  File "/Users/tommy/.virtualenvs/aai/lib/python3.5/site-packages/six.py", line 686, in reraise
    raise value
  File "/Users/tommy/.virtualenvs/aai/lib/python3.5/site-packages/connexion/api.py", line 192, in add_paths
    self.add_operation(method, path, endpoint, path_parameters)
  File "/Users/tommy/.virtualenvs/aai/lib/python3.5/site-packages/connexion/api.py", line 165, in add_operation
    resolver=self.resolver)
  File "/Users/tommy/.virtualenvs/aai/lib/python3.5/site-packages/connexion/operation.py", line 172, in __init__
    resolution = resolver.resolve(self)
  File "/Users/tommy/.virtualenvs/aai/lib/python3.5/site-packages/connexion/resolver.py", line 51, in resolve
    return Resolution(self.resolve_function_from_operation_id(operation_id), operation_id)
  File "/Users/tommy/.virtualenvs/aai/lib/python3.5/site-packages/connexion/resolver.py", line 72, in resolve_function_from_operation_id
    return self.function_resolver(operation_id)
  File "/Users/tommy/.virtualenvs/aai/lib/python3.5/site-packages/connexion/utils.py", line 109, in get_function_from_name
    function = deep_getattr(module, attr_path)
  File "/Users/tommy/.virtualenvs/aai/lib/python3.5/site-packages/connexion/utils.py", line 91, in deep_getattr
    return functools.reduce(getattr, attr.split('.'), obj)
AttributeError: module 'controllers' has no attribute 'controller'

Steps to reproduce

Have an import error in the module that handles an endpoint. In this case my swagger.yaml had the line: operationId: "controllers.controller.tenant_vmname_get", but " controllers.controller had an import error.

Additional info:

Output of the commands:

  • python --version

Python 3.5.0

  • pip show connexion | grep "^Version\:"

Version: 1.0.91

@KarimJedda
Copy link

I second this one, happened so many times to me and didn't understand why.

@hjacobs
Copy link
Contributor

hjacobs commented May 1, 2016

I guess we have to change this function and optionally (if "debug" is set?) print all ImportErrors:
https://github.com/zalando/connexion/blob/master/connexion/utils.py#L94

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

4 participants