View Issue Details

IDProjectCategoryView StatusLast Update
0004838Talerdeployment and operationspublic2018-04-15 18:36
ReporterMarcello Stanisci Assigned ToFlorian Dold Resolution deadline
ImplementerReviewer 
Release signed byDeployed by 
VerifierCommunicator 
Data protection authority notification requiredNo  
CSIRT notification requiredNo  
Estimated effort (hours)Actual effort (hours)0 
Fast-trackNo
Work packagenone
PrioritynormalSeverityminorReproducibilityhave not tried
Status closedResolutionfixed 
Product Versiongit (master) 
Target Version0.5Fixed in Version0.5 
Summary0004838: nginx polluting errors
DescriptionSometimes, for example when a request from a frontend to the backend takes too long to return,
nginx returns (to the frontend) its own "502 Bad gateway" error having in the body the classic
HTML page "Bad gateway" page. This interferes with error management because the frontend always
expects an error to be in JSON format (or at least never HTML), as the backend would normally do.
Steps To ReproduceIn the backoffice interface, try to track a WTID against a non existent exchange.
Before the backend figures out that the given exchange doesn't exist, nginx will
"inject" its own (502) error and return it to the frontend.
Additional InformationThe effect of this bug, affecting BackendError exceptions.

INFO:talerfrontends.common_routes:serving /track/transfer, K2FZAHSCNJBTHRD94FHNVG7811WKCH8AHF6C25PRZGGQ1BTCJ22G/http://blonsa/Taler
INFO:requests.packages.urllib3.connectionpool:Starting new HTTP connection (1): localshop
ERROR:talerfrontends.helpers:failed to GET to 'http://localshop/track/transfer'
INFO:talerfrontends.helpers:<html>
<head><title>502 Bad Gateway</title></head>
<body bgcolor="white">
<center><h1>502 Bad Gateway</h1></center>
<hr><center>nginx/1.10.1</center>
</body>
</html>

Traceback (most recent call last):
  File "/home/marcello/.local/lib/python3.5/site-packages/flask/app.py", line 2000, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/marcello/.local/lib/python3.5/site-packages/flask/app.py", line 1991, in wsgi_app
    response = self.make_response(self.handle_exception(e))
  File "/home/marcello/.local/lib/python3.5/site-packages/flask/app.py", line 1567, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/marcello/.local/lib/python3.5/site-packages/flask/_compat.py", line 33, in reraise
    raise value
  File "/home/marcello/.local/lib/python3.5/site-packages/flask/app.py", line 1988, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/marcello/.local/lib/python3.5/site-packages/flask/app.py", line 1641, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/marcello/.local/lib/python3.5/site-packages/flask/app.py", line 1545, in handle_user_exception
    return handler(e)
  File "/home/marcello/merchant-frontends/talerfrontends/helpers.py", line 343, in handle_backend_error
    jerror = json.loads(error.response)
  File "/usr/lib/python3.5/json/__init__.py", line 319, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python3.5/json/decoder.py", line 339, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python3.5/json/decoder.py", line 357, in raw_decode
    raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
13/Dec/2016:18:37:23 +0100 HTTP/1.1 GET /track/transfer?wtid=K2FZAHSCNJBTHRD94FHNVG7811WKCH8AHF6C25PRZGGQ1BTCJ22G&exchange-uri=http%3A%2F%2Fblonsa&instance=Taler HTTP/1.1 => 500
TagsNo tags attached.

Required notifications

Address or linkRemarkAdded byNotifiedActions

Activities

Marcello Stanisci

2016-12-21 16:57

reporter   ~0011603

Running the frontend without a backend should also reproduce that.

Florian Dold

2018-01-31 17:54

manager   ~0012845

The frontends now handle this properly, we simply check if we can parse the response as JSON.

In fact all frontends *have* to handle this, since in real world deployments we don't control error pages, there might be some load balancer or reverse proxy that gives a non-JSON error page, that's completely normal.

By making NGINX return error pages in JSON form we'd just get problems down the line later when we don't handle this properly.

Issue History

Date ModifiedUsernameFieldChange
2016-12-13 17:46Marcello StanisciNew Issue
2016-12-13 17:46Marcello StanisciAssigned To => Marcello Stanisci
2016-12-13 17:46Marcello StanisciStatusnew => assigned
2016-12-21 16:57Marcello StanisciNote Added: 0011603
2018-01-30 07:35Christian GrothoffProduct Version => git (master)
2018-01-30 07:35Christian GrothoffTarget Version => 0.6
2018-01-31 17:54Florian DoldAssigned ToMarcello Stanisci => Florian Dold
2018-01-31 17:54Florian DoldStatusassigned => informing
2018-01-31 17:54Florian DoldResolutionopen => fixed
2018-01-31 17:54Florian DoldNote Added: 0012845
2018-01-31 17:54Florian DoldTarget Version0.6 => 0.5
2018-04-15 18:35Christian GrothoffFixed in Version => 0.5
2018-04-15 18:36Christian GrothoffStatusinforming => closed