GET /v2.0 HTTP/1.1 gives internal server error

Bug #1014591 reported by Harsh Prasad
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
neutron
Expired
Low
Unassigned

Bug Description

When we query server with GET /v2.0 HTTP/1.1 the server response is 500 Internal server error with following error in response body:

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/eventlet-0.9.16-py2.7.egg/eventlet/wsgi.py", line 336, in handle_one_response
    result = self.application(self.environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/Paste-1.7.5.1-py2.7.egg/paste/urlmap.py", line 203, in __call__
    return app(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/webob/dec.py", line 144, in __call__
    return resp(environ, start_response)
  File "/usr/local/lib/python2.7/dist-packages/Routes-1.13-py2.7.egg/routes/middleware.py", line 80, in __call__
    config.environ = environ
  File "/usr/local/lib/python2.7/dist-packages/Routes-1.13-py2.7.egg/routes/__init__.py", line 22, in __setattr__
    self.load_wsgi_environ(value)
  File "/usr/local/lib/python2.7/dist-packages/Routes-1.13-py2.7.egg/routes/__init__.py", line 51, in load_wsgi_environ
    result = mapper.routematch(path)
  File "/usr/local/lib/python2.7/dist-packages/Routes-1.13-py2.7.egg/routes/mapper.py", line 688, in routematch
    raise RoutesException('URL or environ must be provided')
RoutesException: URL or environ must be provided

I think the server should not reply with its internals in response body.
Also to be noted is that when we query with GET /v2.0/ HTTP/1.1 then server responds with:

<resources><resource collection="subnets" name="subnet"><links><link href="http://127.0.0.1:9696/v2.0/subnets" rel="self"/></links></resource><resource collection="networks" name="network"><links><link href="http://127.0.0.1:9696/v2.0/networks" rel="self"/></links></resource><resource collection="ports" name="port"><links><link href="http://127.0.0.1:9696/v2.0/ports" rel="self"/></links></resource></resources>

which looks kind of appropriate. Should such error be allowed by the server?

Tags: api
Revision history for this message
dan wendlandt (danwent) wrote :

Yes, it would be good to make sure that an internal exception does not result in a traceback being returned to a user. The user should just get a HTTP 500 and an generic message like "Internal server error". We should be sure to log the exception internally though.

Changed in quantum:
status: New → Confirmed
importance: Undecided → Low
Revision history for this message
dan wendlandt (danwent) wrote :

if you are able to work on this, please assign the bug to yourself.

Revision history for this message
Harsh Prasad (prasad-tanay) wrote :

I will look into it. Just want to know what is quantum's policy on trailing slash in url?

Changed in quantum:
assignee: nobody → Harsh Prasad (prasad-tanay)
Revision history for this message
Harsh Prasad (prasad-tanay) wrote :

Also, just to confirm is this error caused by python's eventlet.wsgi??

Revision history for this message
Harsh Prasad (prasad-tanay) wrote :

Hi, this error is in the python's routes.Mapper class . I tried to overwrite the mapper in quantum/api/__init__.py by creating a new class with routematch method, but somehow it is not using this new method. It is using the original method provided by routes/Mapper.py in python dist-packages. I am not sure why it is not using the new method I created?

Revision history for this message
Jason Kölker (jason-koelker) wrote :

Yea this is long standing issue with routes. The general consensus in
the python community is to use nginx or apache to rewrite the urls. The
issue is that when the mapper is called the wsgi environment that does
not have a url part.

This also effects the v1.1 api and the v1.0 and was something on my todo
list to adapt the changes from pyramid that handles the append_slash
stuff over, but ended up needing too much changes to the wsgi stack to
make it not a huge patch since pyramid doesn't use upstream routes
anymore for this and other reasons.

Since it happens in the handoff between the urlmap middleware and
quantum's apps, I'm not sure we really can catch this without monkey
patching prior to loading the paste config.

Revision history for this message
Harsh Prasad (prasad-tanay) wrote :

@jason: We can easily handle this by modifying only two lines in mapper.py and then we can just assign a redirect to "/" so that such error is not received. Can we make changes to python's libraries?

Revision history for this message
Harsh Prasad (prasad-tanay) wrote :

So can we change original python dist-packages?

tags: added: api
removed: quantum quantum-server
goocher (farmerworking)
Changed in neutron:
status: Confirmed → In Progress
goocher (farmerworking)
Changed in neutron:
status: In Progress → Confirmed
Revision history for this message
Cedric Brandily (cbrandily) wrote :

Pre-expire bug with no real activity in the last 3 years

Changed in neutron:
status: Confirmed → Incomplete
assignee: Harsh Prasad (prasad-tanay) → nobody
Revision history for this message
Launchpad Janitor (janitor) wrote :

[Expired for neutron because there has been no activity for 60 days.]

Changed in neutron:
status: Incomplete → Expired
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.