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

return data statement code path where data is not set #907

Closed
maruel opened this issue Mar 14, 2024 · 1 comment · Fixed by #909
Closed

return data statement code path where data is not set #907

maruel opened this issue Mar 14, 2024 · 1 comment · Fixed by #909

Comments

@maruel
Copy link
Contributor

maruel commented Mar 14, 2024

Version of the custom_component

HEAD as of now; 1c59bc2

Describe the bug

data is set on line 461 but if IncompleteCredentials triggers, it does a reload and still return data that is not existing. I think a return after lin 474 would fix the exception.

Debug log

2024-03-13 21:29:00.273 ERROR (MainThread) [custom_components.tesla_custom] Unexpected error fetching tesla_custom data: cannot access local variable 'data' where it is not associated with a value     
Traceback (most recent call last):                                                                                                                                                                       
  File "/usr/src/homeassistant/homeassistant/helpers/update_coordinator.py", line 313, in _async_refresh                                                                                                 
    self.data = await self._async_update_data()                                                                                                                                                          
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^                                                                                                                                                          
  File "/config/custom_components/tesla_custom/__init__.py", line 484, in _async_update_data                                                                                                                 return data                                                                                                                                                                                          
           ^^^^                                                                                                                                                                                          UnboundLocalError: cannot access local variable 'data' where it is not associated with a value 
@alandtse
Copy link
Owner

Please go ahead and submit a PR if you see a solution.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants