Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

AttributeError when displaying an asset which has only public sensors #513

Closed
nhoening opened this issue Oct 13, 2022 · 1 comment · Fixed by #514
Closed

AttributeError when displaying an asset which has only public sensors #513

nhoening opened this issue Oct 13, 2022 · 1 comment · Fixed by #514
Labels
bug Something isn't working

Comments

@nhoening
Copy link
Contributor

I ran into an error when displaying an asset which has only public sensors (a weather station):

[FLEXMEASURES][2022-10-13 13:06:39,484] ERROR: AttributeError:"'NoneType' object has no attribute 'id'" [occurred at /home/nicolas/workspace/seita/flexmeasures/flexmeasures/data/services/sensors.py(get_sensors):26,URL was: /api/v3_0/assets/10/chart/]
Traceback (most recent call last):
  File "/home/nicolas/envs/fm-venv/lib/python3.10/site-packages/flask/app.py", line 1523, in full_dispatch_request
    rv = self.dispatch_request()
  File "/home/nicolas/envs/fm-venv/lib/python3.10/site-packages/flask/app.py", line 1509, in dispatch_request
    return self.ensure_sync(self.view_functions[rule.endpoint])(**req.view_args)
  File "/home/nicolas/envs/fm-venv/lib/python3.10/site-packages/flask_classful.py", line 268, in proxy
    response = view(**request.view_args)
  File "/home/nicolas/envs/fm-venv/lib/python3.10/site-packages/flask_classful.py", line 239, in inner
    return fn(*args, **kwargs)
  File "/home/nicolas/envs/fm-venv/lib/python3.10/site-packages/webargs/core.py", line 594, in wrapper
    return func(*args, **kwargs)
  File "/home/nicolas/envs/fm-venv/lib/python3.10/site-packages/webargs/core.py", line 594, in wrapper
    return func(*args, **kwargs)
  File "/home/nicolas/workspace/seita/flexmeasures/flexmeasures/auth/decorators.py", line 154, in decorated_view
    return fn(*args, **kwargs)
  File "/home/nicolas/workspace/seita/flexmeasures/flexmeasures/api/v3_0/assets.py", line 287, in get_chart
    return json.dumps(asset.chart(**kwargs))
  File "/home/nicolas/workspace/seita/flexmeasures/flexmeasures/data/models/generic_assets.py", line 296, in chart
    sensors = self.sensors_to_show
  File "/home/nicolas/workspace/seita/flexmeasures/flexmeasures/data/models/generic_assets.py", line 451, in sensors_to_show
    for sensor in get_sensors(
  File "/home/nicolas/workspace/seita/flexmeasures/flexmeasures/data/services/sensors.py", line 26, in get_sensors
    account_ids = [account.id]
AttributeError: 'NoneType' object has no attribute 'id'

This error wasn't happening on main recently, so I believe it was introduced with #500 .

@nhoening nhoening added the bug Something isn't working label Oct 13, 2022
@nhoening
Copy link
Contributor Author

I guess in get_sensors, we should check for account being None, and then account_ids = [].

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant