Internal Server Error returned for invald input
Closed this issue · 0 comments
bmario commented
When for instance the from
and to
fields are not formatted properly, the metricq code throws an exception, however the server just returns http status code 500 instead of 4xx. We probably should return 400.
For instance:
Error handling request
Traceback (most recent call last):
File "/home/service/envs/grafana/lib/python3.7/site-packages/aiohttp/web_protocol.py", line 418, in start
resp = await task
File "/home/service/envs/grafana/lib/python3.7/site-packages/aiohttp/web_app.py", line 458, in _handle
resp = await handler(request)
File "/home/service/metricq-grafana/metricq_grafana/views.py", line 19, in query
resp = await get_history_data(request.app, req_json)
File "/home/service/metricq-grafana/metricq_grafana/amqp.py", line 30, in get_history_data
start_time = Timestamp.from_iso8601(request["range"]["from"])
File "/home/service/envs/grafana/lib/python3.7/site-packages/metricq/types.py", line 173, in from_iso8601
datetime.datetime.strptime(iso_string, "%Y-%m-%dT%H:%M:%S.%fZ").replace(
File "/home/service/envs/grafana/lib/python3.7/_strptime.py", line 577, in _strptime_datetime
tt, fraction, gmtoff_fraction = _strptime(data_string, format)
File "/home/service/envs/grafana/lib/python3.7/_strptime.py", line 359, in _strptime
(data_string, format))
ValueError: time data 'Fri Aug 14 2020 00:00:00 GMT+0200' does not match format '%Y-%m-%dT%H:%M:%S.%fZ'