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
18 stars 11 forks source link

AttributeError: 'NoneType' object has no attribute 'source_timeseries' #364

Closed aptiko closed 4 years ago

aptiko commented 4 years ago
Internal Server Error: /api/stations/1458/timeseries/9620/data/

AttributeError at /api/stations/1458/timeseries/9620/data/
'NoneType' object has no attribute 'source_timeseries'

Request Method: POST
Request URL: https://system.openhi.net/api/stations/1458/timeseries/9620/data/
Django Version: 2.2.2
Python Executable: /opt/enhydris-openhi/venv/bin/python3
Python Version: 3.7.3
Python Path: ['/opt/enhydris-openhi', '/opt/enhydris-openhi', '/opt/enhydris-openhi/venv/bin', '/etc/opt/enhydris/openhi', '/opt/enhydris-openhi/venv/lib/python37.zip', '/opt/enhydris-openhi/venv/lib/python3.7', '/opt/enhydris-openhi/venv/lib/python3.7/lib-dynload', '/usr/lib/python3.7', '/opt/enhydris-openhi/venv/lib/python3.7/site-packages', '/usr/local/lib/python3.7/dist-packages', '/usr/lib/python3/dist-packages']
Server time: Tue, 27 Oct 2020 01:15:05 +0200
Installed Applications:
['django.contrib.auth',
 'django.contrib.contenttypes',
 'django.contrib.messages',
 'django.contrib.sessions',
 'django.contrib.staticfiles',
 'django.contrib.sites',
 'django.contrib.humanize',
 'django.contrib.gis',
 'django.contrib.flatpages',
 'django.contrib.postgres',
 'rest_framework',
 'rest_framework.authtoken',
 'rest_auth',
 'bootstrap3',
 'allauth',
 'allauth.account',
 'allauth.socialaccount',
 'rest_auth.registration',
 'rest_captcha',
 'enhydris',
 'enhydris.api',
 'django.contrib.admin',
 'rules.apps.AutodiscoverRulesConfig',
 'parler',
 'nested_admin',
 'enhydris_synoptic',
 'enhydris_autoprocess',
 'enhydris_openhigis']
Installed Middleware:
['django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.locale.LocaleMiddleware',
 'django.middleware.common.CommonMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.middleware.gzip.GZipMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware',
 'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware']

Traceback:

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/core/handlers/exception.py" in inner
  34.             response = get_response(request)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
  115.                 response = self.process_exception_by_middleware(e, request)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
  113.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/views/decorators/csrf.py" in wrapped_view
  54.         return view_func(*args, **kwargs)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/rest_framework/viewsets.py" in view
  114.             return self.dispatch(request, *args, **kwargs)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/rest_framework/views.py" in dispatch
  505.             response = self.handle_exception(exc)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/rest_framework/views.py" in handle_exception
  465.             self.raise_uncaught_exception(exc)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/rest_framework/views.py" in raise_uncaught_exception
  476.         raise exc

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/rest_framework/views.py" in dispatch
  502.             response = handler(request, *args, **kwargs)

File "/opt/enhydris-openhi/enhydris/api/views.py" in data
  211.             return self._post_data(request, pk)

File "/opt/enhydris-openhi/enhydris/api/views.py" in _post_data
  311.             atimeseries.append_data(StringIO(request.data["timeseries_records"]))

File "/opt/enhydris-openhi/enhydris/models.py" in append_data
  634.         self.save()

File "/opt/enhydris-openhi/enhydris/models.py" in save
  677.         super(Timeseries, self).save(force_insert, force_update, *args, **kwargs)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/db/models/base.py" in save
  741.                        force_update=force_update, update_fields=update_fields)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/db/models/base.py" in save_base
  790.                 update_fields=update_fields, raw=raw, using=using,

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/dispatch/dispatcher.py" in send
  175.             for receiver in self._live_receivers(sender)

File "/opt/enhydris-openhi/venv/lib/python3.7/site-packages/django/dispatch/dispatcher.py" in <listcomp>
  175.             for receiver in self._live_receivers(sender)

File "/opt/enhydris-openhi/enhydris_autoprocess/apps.py" in enqueue_auto_process
  10.         for auto_process in instance.timeseries_group.autoprocess_set.all()

File "/opt/enhydris-openhi/enhydris_autoprocess/apps.py" in <listcomp>
  11.         if auto_process.as_specific_instance.source_timeseries == instance

Exception Type: AttributeError at /api/stations/1458/timeseries/9620/data/
Exception Value: 'NoneType' object has no attribute 'source_timeseries'
Request information:
USER: pdedou

GET: No GET data

POST:
timeseries_records = '2020-10-26 00:30:00,,\n2020-10-26 01:00:00,,\n2020-10-26 01:30:00,,\n2020-10-26 02:00:00,,\n2020-10-26 02:30:00,,\n2020-10-26 03:00:00,,\n2020-10-26 03:30:00,,\n2020-10-26 04:00:00,,\n2020-10-26 04:30:00,,\n2020-10-26 05:00:00,,\n2020-10-26 05:30:00,,\n2020-10-26 06:00:00,,\n2020-10-26 06:30:00,,\n2020-10-26 07:00:00,,\n2020-10-26 07:30:00,,\n2020-10-26 08:00:00,,\n2020-10-26 08:30:00,,\n2020-10-26 09:00:00,,\n2020-10-26 09:30:00,,\n2020-10-26 10:00:00,,\n2020-10-26 10:30:00,,\n2020-10-26 11:00:00,,\n2020-10-26 11:30:00,,\n2020-10-26 12:00:00,,\n2020-10-26 12:30:00,,\n2020-10-26 13:00:00,,\n2020-10-26 13:30:00,,\n2020-10-26 14:00:00,,\n2020-10-26 14:30:00,,\n2020-10-26 15:00:00,,\n2020-10-26 15:30:00,,\n2020-10-26 16:00:00,,\n2020-10-26 16:30:00,,\n2020-10-26 17:00:00,,\n2020-10-26 17:30:00,,\n2020-10-26 18:00:00,,\n2020-10-26 18:30:00,,\n2020-10-26 19:00:00,,\n2020-10-26 19:30:00,,\n2020-10-26 20:00:00,,\n2020-10-26 20:30:00,,\n2020-10-26 21:00:00,,\n2020-10-26 21:30:00,,\n2020-10-26 22:00:00,,\n2020-10-26 22:30:00,,\n2020-10-26 23:00:00,,\n2020-10-26 23:30:00,,\n2020-10-27 00:00:00,,\n'

FILES: No FILES data
aptiko commented 4 years ago

The problem is that when a Checks or CurveInterpolation object is deleted, the parent AutoProcess object isn't also deleted.

aptiko commented 4 years ago

No, actually when a Checks or CurveInterpolation or Aggregation object is deleted, the parent AutoProcess is deleted. However there were eight orphan AutoProcess objects (without subclass). I don't know what caused them. I deleted them. If this happens again, we'll re-check. Closing.