Skip to content

Out of range float values are not JSON compliant

Yesterday (April 5) and today (April 6) I got notified about json encoding errors for a couple of pycbc test events:

Traceback (most recent call last):
  File "/usr/local/lib/python3.7/dist-packages/django/core/handlers/exception.py", line 47, in inner
    response = get_response(request)
  File "/usr/local/lib/python3.7/dist-packages/django/core/handlers/base.py", line 204, in _get_response
    response = response.render()
  File "/usr/local/lib/python3.7/dist-packages/django/template/response.py", line 105, in render
    self.content = self.rendered_content
  File "/usr/local/lib/python3.7/dist-packages/rest_framework/response.py", line 70, in rendered_content
    ret = renderer.render(self.data, accepted_media_type, context)
  File "/usr/local/lib/python3.7/dist-packages/rest_framework/renderers.py", line 103, in render
    allow_nan=not self.strict, separators=separators
  File "/usr/local/lib/python3.7/dist-packages/rest_framework/utils/json.py", line 25, in dumps
    return json.dumps(*args, **kwargs)
  File "/usr/lib/python3.7/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "/usr/lib/python3.7/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/usr/lib/python3.7/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)

Exception Type: ValueError at /api/events/
Exception Value: Out of range float values are not JSON compliant
Request information:
USER: prasia.p@ligo.org

GET: No GET data

POST:
search = 'AllSky'
pipeline = 'pycbc'
eventFile = 'text/xml'
group = 'Test'
offline = 'True'

An example of the event is here: https://gracedb-playground.ligo.org/events/T979324/view/

There are a couple of nans in the coinc upload that are causing problems with json serialization.

I think gracedb is robust enough to catch the nan and then store it in the database, but when the event gets serialized to json for alerts and http responses, the error pops up. For example, if one were to look at the api view for that event, the user would get the error instead of a json serialization (plz don't).

Also it would cause errors in nagios/dashboard, because it tries to pull the json packet of the latest event, but if one of these is the latest event, then it gets an error instead.

@prasia.p @tito-canton

To upload designs, you'll need to enable LFS and have an admin enable hashed storage. More information