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

Perform extra checks before allowing report creation. #312

Open sentry-io[bot] opened 3 years ago

sentry-io[bot] commented 3 years ago

User reported that they created a report for power and irradiance and were met with an unhelpful error message. Users should be informed that units must match until https://github.com/SolarArbiter/solarforecastarbiter-core/issues/514 is resolved.

Currently if units do not match for all pairs in the report, the report creation does not catch the problem and an error is raised at computation. Perhaps this can be addressed by trying to instantiate a data model object from the posted report? This may simplify keeping these restrictions in sync between packages.

Sentry Issue: WORKER-API-4K

ValueError: All units must be identical.
(8 additional frame(s) were not displayed)
...
  File "solarforecastarbiter/datamodel.py", line 184, in _single_field_processing
    return type_.from_dict(val)
  File "solarforecastarbiter/datamodel.py", line 295, in from_dict
    return model(**kwargs)
  File "<string>", line 12, in __init__
    from typing import Tuple, Union, ClassVar
  File "solarforecastarbiter/datamodel.py", line 1948, in __post_init__
    (k.forecast, k.data_object) for k in self.object_pairs))
  File "solarforecastarbiter/datamodel.py", line 1270, in __check_units__
    raise ValueError('All units must be identical.')
wholmgren commented 3 years ago

@lboeman do we also need an issue in dashboard? I thought that the form logic was supposed to prevent this.

lboeman commented 3 years ago

@lboeman do we also need an issue in dashboard? I thought that the form logic was supposed to prevent this.

The dashboard form logic does prevent users from selecting pairs with different units, so I don't think we need an issue there unless we can confirm there is a bug there. I did not confirm that the report was generated through direct interaction with the API, so perhaps there is a dashboard issue but not that I could identify by trying to replicate the error.