Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix: 'key not found' exception in bgp4.py (#192)
**- What I did** A 'key not found' exception will be raised in bgp4.py if the state for a given neighbor is not found in STATE_DB. ``` ERR snmp#snmp-subagent [ax_interface] ERROR: MIBUpdater.start() caught an unexpected exception during update_data() #012Traceback (most recent call last): #12 File "/usr/local/lib/python3.7/dist-packages/ax_interface/mib.py", line 43, in start #12 self.update_data()#12 File "/usr/local/lib/python3.7/dist-packages/sonic_ax_impl/mibs/vendor/cisco/bgp4.py", line 42, in update_data #12 state = neigh_info['state'] #12 File "/usr/lib/python3/dist-packages/swsscommon/swsscommon.py", line 345, in __getitem__ #12 return _swsscommon.FieldValueMap___getitem__(self, key) #012IndexError: key not found ``` It is becaues an empty ```dict``` is returned by ```get_all``` when nothing is found for the given key. So check for ```None``` can't detect the error. **- How I did it** This commit addressed the issue by checking the key ```state```. **- How to verify it** Verified on A7260. No exception is observed after the update. **- Description for the changelog** This PR fix exception caused by non existing key.
- Loading branch information