vapor-ware / synse-server

An HTTP API for monitoring and controlling physical and virtual devices
https://synse.readthedocs.io/en/latest/server/intro/
GNU General Public License v3.0
39 stars 11 forks source link

bug: request fails in metrics middleware handling of streamed response #396

Closed edaniszewski closed 4 years ago

edaniszewski commented 4 years ago

bug noticed by @lazypower

When the read_cache endpoint is hit, it returns data as a stream, but the response middleware used to collect app metrics for synse-server apparently is failing to handle streamed responses correctly

timestamp='2020-06-24T15:02:46.466188Z' logger='sanic.error' level='error' event='Exception occurred in one of response middleware handlers' request_id='6Va5Toht4R3crknzJ6ue2o' exception='Traceback (most recent call last):\n  File "/usr/local/lib/python3.8/site-packages/sanic/app.py", line 1016, in handle_request\n    response = await self._run_response_middleware(\n  File "/usr/local/lib/python3.8/site-packages/sanic/app.py", line 1313, in _run_response_middleware\n    _response = middleware(request, response)\n  File "/usr/local/lib/python3.8/site-packages/synse_server/app.py", line 77, in on_response\n    bytes=len(response.body),\nAttributeError: \'StreamingHTTPResponse\' object has no attribute \'body\''

A check should be added for this case, as well as regression test case(s).

edaniszewski commented 4 years ago

This isn't actually with the metrics middleware as I originally thought, but with another middleware function