SolarArbiter / solarforecastarbiter-api

HTTP API and database schema for the Solar Forecast Arbiter
https://api.solarforecastarbiter.org
MIT License
10 stars 6 forks source link

check if forecast df is empty before accessing index #300

Closed sentry-io[bot] closed 3 years ago

sentry-io[bot] commented 3 years ago

Sentry Issue: API-5M

IndexError: index 0 is out of bounds for axis 0 with size 0
(6 additional frame(s) were not displayed)
...
  File "flask/views.py", line 89, in view
    return self.dispatch_request(*args, **kwargs)
  File "flask/views.py", line 163, in dispatch_request
    return meth(*args, **kwargs)
  File "sfa_api/forecasts.py", line 258, in post
    forecast_id, forecast_df.index[0])
  File "pandas/core/indexes/extension.py", line 209, in __getitem__
    result = self._data[key]
  File "pandas/core/arrays/datetimelike.py", line 514, in __getitem__
    val = getitem(key)