openmeteo / enhydris

A database with a web interface for the storage and management of hydro/meteorological measurements and time series
GNU Affero General Public License v3.0
16 stars 11 forks source link

'Index' object has no attribute 'tzinfo' #489

Closed aptiko closed 1 year ago

aptiko commented 1 year ago

/api/stations/1428/timeseries/9556/data/?fmt=hts&start_date=2023-02-22T17%3A51%3A00

Traceback (most recent call last):
  File "/opt/enhydris-openmeteo/venv/lib/python3.9/site-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/opt/enhydris-openmeteo/venv/lib/python3.9/site-packages/django/core/handlers/base.py", line 181, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/opt/enhydris-openmeteo/venv/lib/python3.9/site-packages/django/views/decorators/csrf.py", line 54, in wrapped_view
    return view_func(*args, **kwargs)
  File "/opt/enhydris-openmeteo/venv/lib/python3.9/site-packages/rest_framework/viewsets.py", line 125, in view
    return self.dispatch(request, *args, **kwargs)
  File "/opt/enhydris-openmeteo/venv/lib/python3.9/site-packages/rest_framework/views.py", line 509, in dispatch
    response = self.handle_exception(exc)
  File "/opt/enhydris-openmeteo/venv/lib/python3.9/site-packages/rest_framework/views.py", line 469, in handle_exception
    self.raise_uncaught_exception(exc)
  File "/opt/enhydris-openmeteo/venv/lib/python3.9/site-packages/rest_framework/views.py", line 480, in raise_uncaught_exception
    raise exc
  File "/opt/enhydris-openmeteo/venv/lib/python3.9/site-packages/rest_framework/views.py", line 506, in dispatch
    response = handler(request, *args, **kwargs)
  File "/opt/enhydris-openmeteo/enhydris/api/views.py", line 242, in data
    return self._get_data(request, pk)
  File "/opt/enhydris-openmeteo/enhydris/api/views.py", line 338, in _get_data
    ahtimeseries = timeseries.get_data(
  File "/opt/enhydris-openmeteo/enhydris/models/timeseries.py", line 183, in get_data
    data = self._get_data_from_cache(start_date, end_date)
  File "/opt/enhydris-openmeteo/enhydris/models/timeseries.py", line 199, in _get_data_from_cache
    start_date = max(start_date, self.start_date).astimezone(data.index.tzinfo)

Exception Type: AttributeError at /api/stations/1428/timeseries/9556/data/
Exception Value: 'Index' object has no attribute 'tzinfo'

Request information:
USER: AnonymousUser

GET:
fmt = 'hts'
start_date = '2023-02-22T17:51:00'
aptiko commented 1 year ago

This seems to be caused by an ancient enhydris-cache version (0.1.1) running on megdobas. It shouldn't result in an internal server error though.

aptiko commented 1 year ago

It doesn't seem to be repeatable. I try the URL and it succeeds. However it occurs almost every evening.