From a99d56da132019c94b89d17524ab66bc7504f7e8 Mon Sep 17 00:00:00 2001 From: Qi Luo Date: Wed, 18 Aug 2021 03:33:34 -0700 Subject: [PATCH] Improve config error handling on version_info (#1760) #### What I did `get_sonic_version_info()` may return `None` if `/etc/sonic/sonic_version.yml` does not exist. Previously the `config` exit without any useful information. Some `config` subcommands do not depend on sonic version info, we should allow them to run. --- config/main.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/config/main.py b/config/main.py index a80283f7ee..14aae25e62 100644 --- a/config/main.py +++ b/config/main.py @@ -950,8 +950,12 @@ def config(ctx): try: version_info = device_info.get_sonic_version_info() - asic_type = version_info['asic_type'] - except (KeyError, TypeError): + if version_info: + asic_type = version_info['asic_type'] + else: + asic_type = None + except (KeyError, TypeError) as e: + print("Caught an exception: " + str(e)) raise click.Abort() # Load database config files