Unhandled exception on 504 error

Bug #1358889 reported by Kurt Griffiths
This bug affects 1 person
Affects Status Importance Assigned to Milestone
Python client library for Zaqar
Fix Released
Shaifali Agrawal

Bug Description

A load balancer/proxy such as HAProxy may return 504 and an HTML body. In that case, the client raises a ValueError in transport/response.py when it attempts to decode the body.

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/gevent/greenlet.py", line 327, in run
    result = self._run(*self.args, **self.kwargs)
  File "/root/zaqar/zaqar/bench/producer.py", line 86, in producer
  File "/usr/local/lib/python2.7/dist-packages/marconiclient/queues/v1/queues.py", line 104, in post
    self._name, messages)
  File "/usr/local/lib/python2.7/dist-packages/marconiclient/queues/v1/core.py", line 193, in message_post
    return resp.deserialized_content
  File "/usr/local/lib/python2.7/dist-packages/marconiclient/transport/response.py", line 47, in deserialized_content
    self._deserialized = json.loads(self.content)
  File "/usr/lib/python2.7/json/__init__.py", line 326, in loads
    return _default_decoder.decode(s)
  File "/usr/lib/python2.7/json/decoder.py", line 365, in decode
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())
  File "/usr/lib/python2.7/json/decoder.py", line 383, in raw_decode
    raise ValueError("No JSON object could be decoded")
ValueError: No JSON object could be decoded

Kurt Griffiths (kgriffs)
description: updated
Changed in python-zaqarclient:
assignee: nobody → Shaifali Agrawal (agrawalshaifali09)
Revision history for this message
Flavio Percoco (flaper87) wrote :

Can the LB be configured to return something else instead of the HTML? Why should zaqarclient care about this?

I may be wrong here but I think it's completely fair to just assume the response is of the expected type. We could add a check on the content-type but then we also need to answer the question of what the client should do if the content-type is not supported. Should it raise an exception? Should the 504 be communicated back to the user?

Revision history for this message
Kurt Griffiths (kgriffs) wrote :

The LB could certainly be changed to not do this. However, this is just one case where an unexpected response may be returned. If nothing else, the client should at least not crash with an unhandled exception.

Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix proposed to python-zaqarclient (master)

Fix proposed to branch: master
Review: https://review.openstack.org/136816

Changed in python-zaqarclient:
status: New → In Progress
Revision history for this message
Victoria Martinez de la Cruz (vkmc) wrote :

Agree with Kurt that, whereas is not responsibility of the client to check the content-type of the response, we shouldn't allow the client to crash with an unhandled exception.

Changed in python-zaqarclient:
importance: Undecided → Medium
Revision history for this message
OpenStack Infra (hudson-openstack) wrote : Fix merged to python-zaqarclient (master)

Reviewed: https://review.openstack.org/136816
Committed: https://git.openstack.org/cgit/openstack/python-zaqarclient/commit/?id=ff13b7a6ac002e7aebb4587aa7e81bac864b6dc6
Submitter: Jenkins
Branch: master

commit ff13b7a6ac002e7aebb4587aa7e81bac864b6dc6
Author: Shaifali Agrawal <email address hidden>
Date: Mon Nov 24 08:42:27 2014 -0800

    Handling exception on 504 Error

    When load balancer/proxy return 504, client raises ValueError.
    This happen when response is not a JSON object.
    ValueError Exception is needed to be handled.

    Change-Id: Iaa8d577f99137327f6e7ad9c7c6abc350f4cc938
    Closes-Bug: #1358889

Changed in python-zaqarclient:
status: In Progress → Fix Committed
Changed in python-zaqarclient:
milestone: none → 0.2.0
status: Fix Committed → Fix Released
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.