FAI-CIVL / FAI-Airscore

AirScore - online paragliding / hanggliding GAP-based scoring software.
https://airscore.cc/
GNU General Public License v3.0
13 stars 17 forks source link

Last altitude float cannot be coerced from NoneType. #213

Closed philderbeast closed 3 years ago

philderbeast commented 3 years ago

Importing the *.fsdb from the HG Worlds at 4b1628a2c35cb74bccdbb41d416fddbc822e14d6 fails:

POST http://localhost:5000/users/_import_comp_fsdb/ 500 (INTERNAL SERVER ERROR)
Traceback (most recent call last):
  File "/home/sid/.local/lib/python3.8/site-packages/flask/app.py", line 2464, in __call__
    return self.wsgi_app(environ, start_response)
  File "/home/sid/.local/lib/python3.8/site-packages/flask/app.py", line 2450, in wsgi_app
    response = self.handle_exception(e)
  File "/home/sid/.local/lib/python3.8/site-packages/flask/app.py", line 1867, in handle_exception
    reraise(exc_type, exc_value, tb)
  File "/home/sid/.local/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/home/sid/.local/lib/python3.8/site-packages/flask/app.py", line 2447, in wsgi_app
    response = self.full_dispatch_request()
  File "/home/sid/.local/lib/python3.8/site-packages/flask/app.py", line 1952, in full_dispatch_request
    rv = self.handle_user_exception(e)
  File "/home/sid/.local/lib/python3.8/site-packages/flask/app.py", line 1821, in handle_user_exception
    reraise(exc_type, exc_value, tb)
  File "/home/sid/.local/lib/python3.8/site-packages/flask/_compat.py", line 39, in reraise
    raise value
  File "/home/sid/.local/lib/python3.8/site-packages/flask/app.py", line 1950, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/sid/.local/lib/python3.8/site-packages/flask_debugtoolbar/__init__.py", line 125, in dispatch_request
    return view_func(**req.view_args)
  File "/home/sid/.local/lib/python3.8/site-packages/flask_login/utils.py", line 272, in decorated_view
    return func(*args, **kwargs)
  File "/app/airscore/user/views.py", line 185, in _import_comp_fsdb
    f = FSDB.read(fsdb_file)
  File "/app/airscore/core/fsdb.py", line 106, in read
    pilot = FlightResult.from_fsdb(res, task)
  File "/app/airscore/core/pilot/flightresult.py", line 240, in from_fsdb
    result.last_altitude = float(d.get('last_tracklog_point_alt' or 0))
TypeError: float() argument must be a string or a number, not 'NoneType'
kuaka commented 3 years ago

I have fixed this (and tested with that particular fsdb file) with commit https://github.com/FAI-CIVL/FAI-Airscore/commit/79ed346b8f1285629781bb1296bb9f0439cc2306

@biuti from looking at the code around this it looks like the bug was a typo but maybe you want to check that this pattern is not elsewhere in the fsdb import code.

biuti commented 3 years ago

I'll check.