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

ValueError: Out of range float values are not JSON compliant #429

Closed aptiko closed 3 years ago

aptiko commented 3 years ago
ValueError at /api/stations/1334/timeseriesgroups/677/timeseries/6661/chart/
Out of range float values are not JSON compliant

Request Method: GET
Request URL: https://openmeteo.org/api/stations/1334/timeseriesgroups/677/timeseries/6661/chart/
Django Version: 2.2.2
Python Executable: /opt/enhydris-openmeteo/venv/bin/python3
Python Version: 3.7.3
Python Path: ['/opt/enhydris-openmeteo', '/opt/enhydris-openmeteo', '/opt/enhydris-openmeteo/venv/bin', '/etc/opt/enhydris/openmeteo', '/opt/enhydris-openmeteo/venv/lib/python37.zip', '/opt/enhydris-openmeteo/venv/lib/python3.7', '/opt/enhydris-openmeteo/venv/lib/python3.7/lib-dynload', '/usr/lib/python3.7', '/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages', '/usr/local/lib/python3.7/dist-packages', '/usr/lib/python3/dist-packages']
Server time: Thu, 4 Mar 2021 09:25:21 +0000
Installed Applications:
['enhydris_openhigis',
 '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']
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',
 'enhydris_openhigis.middleware.OpenHiGISMiddleware']

Traceback:

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

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

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response
  143.                 response = response.render()

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/django/template/response.py" in render
  106.             self.content = self.rendered_content

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/rest_framework/response.py" in rendered_content
  70.         ret = renderer.render(self.data, accepted_media_type, context)

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/rest_framework/renderers.py" in render
  103.             allow_nan=not self.strict, separators=separators

File "/opt/enhydris-openmeteo/venv/lib/python3.7/site-packages/rest_framework/utils/json.py" in dumps
  25.     return json.dumps(*args, **kwargs)

File "/usr/lib/python3.7/json/__init__.py" in dumps
  238.         **kw).encode(obj)

File "/usr/lib/python3.7/json/encoder.py" in encode
  199.         chunks = self.iterencode(o, _one_shot=True)

File "/usr/lib/python3.7/json/encoder.py" in iterencode
  257.         return _iterencode(o, 0)

Exception Type: ValueError at /api/stations/1334/timeseriesgroups/677/timeseries/6661/chart/
Exception Value: Out of range float values are not JSON compliant
aptiko commented 3 years ago

This error was occurring because in the database, this time series had a value of "infinity" (for 2009-06-17 12:00). This value does not make sense and should not be there. It was added to the database many Enhydris release ago (and many pandas releases ago, and so on), and it was converted by conversion scripts from CSV to PostgreSQL/Timescale. It is not known whether this can happen again. Changed the value to NULL. Closing this ticket as invalid.