Routes on error and ajax bug

32 views
Skip to first unread message

Alfonso Serra

unread,
Jul 6, 2019, 11:02:54 AM7/6/19
to web...@googlegroups.com
I have been able to reproduce a bug with the welcome app when routes on error is in use on localhost:

Steps to reproduce:
1.- create an app "myapp"
2.- create another app "errors"
3.- Edit routes.py
default_application = 'myapp'    # ordinarily set in base routes.py
default_controller
= 'index'  # ordinarily set in app-specific routes.py
default_function
= 'index'      # ordinarily set in app-specific routes.py
routes_onerror
= [(r'*/*', r'errors/errors/index')]
No routes_in or routes_out defined.

applications/errors/errors.py (error handler)
def index():
    code
= request.vars.code
    ticket
= request.vars.ticket
   
print "processing error"
   
print code
   
print ticket
   
return "Error processed"


applications/myapp/controller/index.py:
response.view = "index.html"
def index():
   
if request.ajax:
       
print "ajax"
       
raise HTTP(404, "Cant do")
       
   
return locals()


applications/myapp/views/index.html
<!DOCTYPE html>
<html>
<head>
   
<title>App</title>
</head>
<body>
<h1>App</h1>
<p>Welcome</p>
<script type="text/javascript" src="/myapp/static/js/jquery.js"></script>
<script type="text/javascript">
function saved(){
    console
.log("got response");
}
$
.post({url: "/", data:{name: "Pepe", last: "Mario"}}, saved)
</script>
</body>
</html>


When the ajax post triggers, we get this error on the console:
ERROR:Rocket.Errors.Thread-2:Traceback (most recent call last):

 
File "C:\Users\Stark\Desktop\Projects\datatabs\gluon\rocket.py", line 1288, in run
   
self.run_app(conn)

 
File "C:\Users\Stark\Desktop\Projects\datatabs\gluon\rocket.py", line 1789, in run_app
    output
= self.app(environ, self.start_response)

 
File "C:\Users\Stark\Desktop\Projects\datatabs\gluon\main.py", line 649, in app_with_logging
    ret
[0] = wsgiapp(environ, responder2)

 
File "C:\Users\Stark\Desktop\Projects\datatabs\gluon\main.py", line 560, in wsgibase
   
return wsgibase(new_environ, responder)

 
File "C:\Users\Stark\Desktop\Projects\datatabs\gluon\main.py", line 530, in wsgibase
   
if request.body:

 
File "C:\Users\Stark\Desktop\Projects\datatabs\gluon\globals.py", line 280, in body
   
raise HTTP(400, "Bad Request - HTTP body is incomplete")

HTTP
: 400 BAD REQUEST

And the response takes 15 seconds with an error 500 instead the 404, "Cant  do" from the controller.


Chasing the console error, for some reaosn it fails at globals.py line 280
self._body = copystream_progress(self)

specifically at copystream globals.py line 126:
 if 'X-Progress-ID' not in request.get_vars:
    copystream
(source, dest, size, chunk_size)
   
return dest
i have tried to change it to request.post_vars but didnt work. Not sure whats wrong.

Because of this issue, raise HTTP(400/500, "message") wont work when routes_onerror is installed.

Any idea what might be wrong?
Version 2.18.5-stable+timestamp.2019.04.08.04.22.03

Thanks
Best Regards.
Reply all
Reply to author
Forward
0 new messages