brutasse / graphite-api

Graphite-web, without the interface. Just the rendering HTTP API.
https://graphite-api.readthedocs.io
Apache License 2.0
492 stars 131 forks source link

glyph: Use explicit None comparison in getExtents #205

Closed lewiseason closed 7 years ago

lewiseason commented 7 years ago

Consistently seeing incorrect behaviour/crashing on the /render endpoint due to the changed line seemingly doing the wrong thing.

(Sorry if my regression test is in the wrong place)

Do a more explicit comparison to ensure the correct thing is being checked, or else I get the following exception:

Traceback (most recent call last):
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1988, in wsgi_app
    response = self.full_dispatch_request()
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1641, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1544, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1639, in full_dispatch_request
    rv = self.dispatch_request()
  File "/usr/lib/python2.7/site-packages/flask/app.py", line 1625, in dispatch_request
    return self.view_functions[rule.endpoint](**req.view_args)
  File "/usr/lib/python2.7/site-packages/graphite_api/app.py", line 455, in render
    image = doImageRender(request_options['graphClass'], graph_options)
  File "/usr/lib/python2.7/site-packages/graphite_api/app.py", line 591, in doImageRender
    img = graphClass(**graphOptions)
  File "/usr/lib/python2.7/site-packages/graphite_api/render/glyph.py", line 383, in __init__
    self.drawGraph(**params)
  File "/usr/lib/python2.7/site-packages/graphite_api/render/glyph.py", line 915, in drawGraph
    self.drawLabels()
  File "/usr/lib/python2.7/site-packages/graphite_api/render/glyph.py", line 1762, in drawLabels
    self.drawText(label, x, y, align='center', valign='top')
  File "/usr/lib/python2.7/site-packages/graphite_api/render/glyph.py", line 452, in drawText
    'center': extents['width'] / 2,
KeyError: 'width'
brutasse commented 7 years ago

Thank you! Lint failure was unrelated, I fixed it in master separately.

lewiseason commented 7 years ago

Yeah, wasn't sure how I'd managed that! Thanks for maintaining graphite-api!