diff --git a/src/sonic-py-common/sonic_py_common/device_info.py b/src/sonic-py-common/sonic_py_common/device_info.py index e52e9ef9eebf..225002b643cc 100644 --- a/src/sonic-py-common/sonic_py_common/device_info.py +++ b/src/sonic-py-common/sonic_py_common/device_info.py @@ -268,7 +268,8 @@ def get_path_to_port_config_file(hwsku=None, asic=None): if os.path.isfile(os.path.join(platform_path, PLATFORM_JSON_FILE)): json_file = os.path.join(platform_path, PLATFORM_JSON_FILE) platform_data = json.loads(open(json_file).read()) - if len(platform_data.get("interfaces")) > 0: + interfaces = platform_data.get('interfaces', None) + if interfaces and len(interfaces) > 0: port_config_candidates.append(os.path.join(platform_path, PLATFORM_JSON_FILE)) # Check for 'port_config.ini' file presence in a few locations