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

[python] handle storage Sync issues properly #17939

Merged

Conversation

agners
Copy link
Contributor

@agners agners commented Apr 30, 2022

The variable "path" doesn't exist when handling this exception. Use
self._file and return after reporting the error to avoid further
exceptions.

Problem

What is being fixed? Examples:

  • Fix crash on startup
2022-04-30 11:00:22 allenwind root[270500] CRITICAL Loading configuration from /tmp/chip-device-ctrl-storage.json...                                                                                                                                                                                                                                                                                                          
2022-04-30 11:00:22 allenwind root[270500] INFO SetSdkKey: g/gcc = b'\xd0\x07\x00\x00'                                                                                                                                                                                                                                                                                                                                        
Exception ignored on calling ctypes callback function: <function _OnSyncSetKeyValueCb at 0x7f6230043af0>                                                                                                                                                                                                                                                                                                                      
Traceback (most recent call last):                                                                                                                                                                                                                                                                                                                                                                                            
  File "/home/sag/projects/project-chip/connectedhomeip/out/python_env/lib/python3.9/site-packages/chip/storage/__init__.py", line 44, in _OnSyncSetKeyValueCb                                                                                                                                                                                                                                                                
    storageObj.SetSdkKey(key.decode("utf-8"), ctypes.string_at(value, size))                                                                                                                                                                                                                                                                                                                                                  
  File "/home/sag/projects/project-chip/connectedhomeip/out/python_env/lib/python3.9/site-packages/chip/storage/__init__.py", line 147, in SetSdkKey                                                                                                                                                                                                                                                                          
    self.Sync()                                                                                                                                                                                                                                                                                                                                                                                                               
  File "/home/sag/projects/project-chip/connectedhomeip/out/python_env/lib/python3.9/site-packages/chip/storage/__init__.py", line 111, in Sync                                                                                                                                                                                                                                                                               
    f"Could not open {path} for writing configuration. Error:")                                                                                                                                                                                                                                                                                                                                                               
NameError: name 'path' is not defined

Change overview

Improve exception handling.

Testing

How was this tested? (at least one bullet point required)

  • If unit tests were added, how do they cover this issue?
  • If unit tests existed, how were they fixed/modified to prevent this in future?
  • If new unit tests are not added, why not?
  • If integration tests were added, how do they verify this change?
  • If new integration tests are not added, why not?
  • If manually tested, what platforms controller and device platforms were manually tested, and how?
  • If no testing is required, why not?

The variable "path" doesn't exist when handling this exception. Use
self._file and return after reporting the error to avoid further
exceptions.
@stale
Copy link

stale bot commented May 13, 2022

This pull request has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

@stale stale bot added the stale Stale issue or PR label May 13, 2022
@agners
Copy link
Contributor Author

agners commented May 14, 2022

Ping, I think this should be ready to be merged.

@stale stale bot removed the stale Stale issue or PR label May 14, 2022
@andy31415 andy31415 merged commit a8f9848 into project-chip:master May 16, 2022
@agners agners deleted the improve-python-storage-exception-handling branch June 29, 2022 22:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants