How to make Bottle print error message in 500 response? - uwsgi

I'm trying to debug why Bottle can no longer find a template, but it doesn't tell me which template is actually missing:
File "/virtualenv/lib/python2.7/site-packages/bottle.py", line 3222, in __init__
raise TemplateError('Template %s not found.' % repr(name))
bottle.TemplateError
Neither the console nor the web page contain the formatted version of Template %s not found. anywhere.
I have enabled debugging (when debugging is disabled the stack trace does not show up on the web page).
The route handler is literally just #bottle.post('/request').
This is distinct from How to make Bottle print stacktrace when running through apache modwsgi?, since the answer there is to enable debugging.
Using the latest stable Bottle, 0.12.13.

This works for me - is your code substantially different? Hoping you'll spot a difference.
from bottle import Bottle, template
app = Bottle()
#app.route('/')
def home():
return template('foo') # template "foo" does not exist
app.run(host='127.0.0.1', port=8080) # Note: no debug required
Response:
% curl http://127.0.0.1:8080/
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html>
<head>
<title>Error: 500 Internal Server Error</title>
<style type="text/css">
html {background-color: #eee; font-family: sans;}
body {background-color: #fff; border: 1px solid #ddd;
padding: 15px; margin: 15px;}
pre {background-color: #eee; border: 1px solid #ddd; padding: 5px;}
</style>
</head>
<body>
<h1>Error: 500 Internal Server Error</h1>
<p>Sorry, the requested URL <tt>'http://127.0.0.1:8080/'</tt>
caused an error:</p>
<pre>Template 'foo' not found.</pre>
</body>
</html>
Note that the error message contains the missing template name:
Template 'foo' not found.

Related

Azure function activity in ADF V2 timeouts after 4min 7sec, even though in code i have mentioned "functionTimeout": "00:10:00" which is 10mins?

I have created an azure function and its timeout is set to 10mins in hosts.json but when I am triggering it through ADF V2 azure function activity then activity is getting terminated after 4mins 7sec, Can any one guide me what is happening at the backend and why I am getting this behavior? Thanks.
Update: If i run my azure function through ADF or from postman it gives me this error after 4min 7sec:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>502 - Web server received an invalid response while acting as a gateway or proxy server.</title>
<style type="text/css">
< !-- body {
margin: 0;
font-size: .7em;
font-family: Verdana, Arial, Helvetica, sans-serif;
background: #EEEEEE;
}
fieldset {
padding: 0 15px 10px 15px;
}
h1 {
font-size: 2.4em;
margin: 0;
color: #FFF;
}
h2 {
font-size: 1.7em;
margin: 0;
color: #CC0000;
}
h3 {
font-size: 1.2em;
margin: 10px 0 0 0;
color: #000000;
}
#header {
width: 96%;
margin: 0 0 0 0;
padding: 6px 2% 6px 2%;
font-family: "trebuchet MS", Verdana, sans-serif;
color: #FFF;
background-color: #555555;
}
#content {
margin: 0 0 0 2%;
position: relative;
}
.content-container {
background: #FFF;
width: 96%;
margin-top: 8px;
padding: 10px;
position: relative;
}
-->
</style>
</head>
<body>
<div id="header">
<h1>Server Error</h1>
</div>
<div id="content">
<div class="content-container">
<fieldset>
<h2>502 - Web server received an invalid response while acting as a gateway or proxy server.</h2>
<h3>There is a problem with the page you are looking for, and it cannot be displayed. When the Web
server (while acting as a gateway or proxy) contacted the upstream content server, it received an
invalid response from the content server.</h3>
</fieldset>
</div>
</div>
</body>
</html>
And if I go to App insights of function App it shows me timeout of 10mins which I think is correct because I am using consumption plan so I know that. But at 4min and 7sec the 502 response which is sent to the client i am not familier with issue. Please guide.
As your function can continue to run as expected even though the 502 error shows, so I think it has nothing to do with your azure function.
As far as I know, azure function activity just allows 230 seconds for the request in data factory. You can refer to this document.
If you want to request it by postman, you can set the "request time out" in the "settings" of your postman. Please refer to this document.
Hope it helps~
Maybe just me, but if true that you are limited to 230 seconds then this is CRAZY. I can definitely run functions for longer than that. In consumption plan up to 10 minutes, in premium plan you can have 60 minutes run time. See here.
If the answer is to use Durable function, then you might as well just implement your workflow in there and forget about ADF completely.
Azure Function ADF Activity tool-tip states that default timeout is 12 hours.
Something doesn't smell right.

Facing intermittent 404 issue when calling Rails API

I have banged my head on this for 2 days now and i dint find any luck yet. Looking for help on this.
The issue:
Front End makes 10 similar XHR requests ( for different users ) to my Rails API and few of the requests randomly fails with 404 status code.
My Observations:
If i make the same request again, It passes.
I dont see any trace of 404 requests even hitting my server ( using logs ).
I do see different response headers for 200 and 404 ( mentioned below ) and i see cowboy ( https://github.com/heroku/cowboyku, https://github.com/heroku/vegur) server for 404 requests. I run my rails production with thin web server.
My theory is that, As few of my requests are not able to hit my thin server, they are getting 404. Now, the confusion is, Why is it hitting cowboy
200 Status Code
404 Status Code
[EDITS]
response payload for 404 errors is something like below.
<!DOCTYPE html>
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta charset="utf-8">
<title>No such app</title>
<style media="screen">
html,body,iframe {
margin: 0;
padding: 0;
}
html,body {
height: 100%;
overflow: hidden;
}
iframe {
width: 100%;
height: 100%;
border: 0;
}
</style>
</head>
<body>
<iframe src="//www.herokucdn.com/error-pages/no-such-app.html"></iframe>
</body>
</html>

iPhone Browsers - Unable to download image

<!DOCTYPE html>
<!--
This page is shown when the extension button is clicked, because the
"browser_action" field in manifest.json contains the "default_popup" key with
value "popup.html".
-->
<html>
<head>
<title>Test title</title>
<style>
body {
font-family: "Segoe UI", "Lucida Grande", Tahoma, sans-serif;
font-size: 100%;
}
#status {
/* avoid an excessively wide status text */
white-space: pre;
text-overflow: ellipsis;
overflow: hidden;
max-width: 400px;
}
</style>
</head>
<body>
<p>Example 1<br>
<a href="http://dummyimage.com/600x400/000/fff.png" download>Download this image</a></p>
</body>
</html>
The above, is a button (kind of) that downloads an image. It works fine on my laptop, but when I navigate to the url on my iPhone it doesn't download. Just takes me to the actual image.
Anyone know why? Or how I can fix this?
Thanks!
iPhone doesn't have a download functionality. You will need to tap-and-hold, and select "Save".

Angular dart: Route links in Safari on iOS 7 stop working

I have been tearing my hair out over this for over a week now...
TL;DR: hash based links stop working in Safari on iOS 7 after a certain number of clicks.
We had a strange issue in our Angular Dart application - people using iPhones reported that links were "freezing" after "a while". The typical non helpful error reports, so we had to work hard to figure out exactly how to replicate the issue.
It eventually became clear that after the same number of clicks each time, Safari on iOS 7 would just stop navigating to the hash based route links.
After much diagnosis (removing bits of the app piece by piece until the issue stopped happening), I've managed to narrow it down to routes which contain parameters. After these routes are followed a certain number of times, Safari on iOS 7 just stops following them - it's like they get "half" clicked - the link gets underlined, but it is never followed, and subsequently no amount of clicking on it will allow it to be followed.
Here is a very simple dart application that will replicate the issue:
In the root folder:
pubspec.yaml:
name: DartRouteChecker
description: A sample web application
dependencies:
angular: 0.14.0
browser: any
transformers:
- angular
Then in the web folder:
dartroutechecker.dart:
library dart_route_checker;
import 'package:angular/angular.dart';
import 'package:angular/application_factory.dart';
class MyAppModule extends Module {
MyAppModule() {
bind(NgRoutingUsePushState, toValue: new NgRoutingUsePushState.value(false));
bind(RouteInitializerFn, toImplementation: Routes);
}
}
void main() {
applicationFactory()
.addModule(new MyAppModule())
.run();
}
#Injectable()
class Routes
{
void call(Router router, RouteViewFactory views) {
views.configure({
'route1': ngRoute(path: '/route1', defaultRoute: true, view: 'route1.html'),
'route2': ngRoute(path: '/route2/:id', view: 'route2.html')
});
}
}
dartroutechecker.html:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>DartRouteChecker</title>
<script async type="application/dart" src="dartroutechecker.dart"></script>
<script async src="packages/browser/dart.js"></script>
<link rel="stylesheet" href="dartroutechecker.css">
</head>
<body>
<ng-view></ng-view>
</body>
</html>
dartroutechecker.css
body {
background-color: #F8F8F8;
font-family: 'Open Sans', sans-serif;
font-size: 14px;
font-weight: normal;
line-height: 1.2em;
margin: 15px;
}
h1, p {
color: #333;
}
#sample_container_id {
width: 100%;
height: 400px;
position: relative;
border: 1px solid #ccc;
background-color: #fff;
}
#sample_text_id {
font-size: 24pt;
text-align: center;
margin-top: 140px;
-webkit-user-select: none;
user-select: none;
}
route1.html:
<h1>ROUTE 1</h1>
<div>
Go to second route
</div>
route2.html:
<h1>ROUTE 2</h1>
<div>
Go to first route
</div>
Use pub build to build the app (generate javascript), then navigate to it using an iPhone with iOS 7 (I tested it on an iPhone 5 and an iPhone 4S both with iOS 7.1.2). Click on "Go to second route" then "Go to first route" over and over again until you get to around 30 clicks - the link will then stop responding... It's almost always exactly 30 clicks that will cause it (though I have once or twice seen it be around 43, though I can't be sure I didn't click something else during those times - I've done so much stinkin' clickin' in the last week that I feel I'm going slightly insane...)
I can't replicate this issue when the iPhone is plugged in to a mac to debug it. It also doesn't happen if neither of the routes contains a parameter. And it happens with FEWER clicks if there are more routes defined in the route initialisation class, or if the routes contain multiple parameters. Initially I thought that the problem might have been that one of our routes had an ampersand in it, but that didn't turn out to be the case. And it doesn't happen at all in any other browsers, including Chrome on iOS.
I suspect this might be a bug in Safari (possibly related to Safari not handling hashchanges correctly, and not handling browser history correctly when using appcache (which, BTW, I am not using here)), but this is a real showstopper for us here - many of our customers are using iPhones, so if our app keeps freezing on the standard browser on an iPhone, we're in a lot of strife.
Has anyone seen anything like this before? Anyone have any suggestions for a workaround? Or a new career?.....
EDIT:
We have tracked the issue down to the route method in route.dart:
https://github.com/angular/route.dart/blob/master/lib/client.dart#L480
In the method gotoUrl (https://github.com/angular/route.dart/blob/master/lib/client.dart#L782), if we change it from route(url).then((success) { to new Future.value(true).then((success) { then the issue no longer occurs - of course then we lose all the "preenter" etc etc functionality that routing provides. But it seems that somewhere in that route function, something is going awry...
According to this issue linked in the comments by Günter, this has been fixed in 0.5.0 by this commit.
I can't understand what part of that commit fixes it from reading the code; so hopefully 0.5 is a relatively compatible version to upgrade to!

Popup message window in grails?

I have a Grails application with a form in it. Once the user has entered the data and submitted it, and it's been validated etc.. I need a message to popup in a little window to give the user some feedback - it needs to popup, rather than be displayed on the page. Can anyone advise me on the best way to do this?
I have implemented the same mechanism for my application, and I am using the jQuery plugin 'smartmodal' (used by the Nimble plugin originally). See here
You simply have to redirect the request in the controller validation code to a GSP page containing the following code:
<script type="text/javascript" src="${resource(file: 'jquery-1.3.2.js')}"></script>
<script type="text/javascript" src="${resource(file:'jquery.smartmodal.js')}"></script>
<LINK rel="stylesheet" href="./css/smartmodal.css">
...
<body>
...
<g:javascript>
$(function() {
$("#msg").hide();
$("#msg").modal({hide_on_overlay_click:false});
$("#msg").modal_show();});
</g:javascript>
<div id="msg">
My feedback message is here
</div>
<g:link controller="..." action="...">Close</g:link>
I hope it helps,
Fabien
EDIT:
An extract of the smartmodal.css file that will render the 'modal effect' is:
#modal_content {
display: none;
position: fixed;
left: 50%;
padding: 0px;
top: 10%;
background: #FFF;
border: 0px solid #d2d2d2;
width: 400px;
margin-left: -200px;
text-align: left;
}
#modal_overlay {
background-color: #000;
}
However if you want the complete file, it is available inside the great Nimble grails plugin

Resources