From deb4e3562d190e0bc77a836bc4a77590ed237452 Mon Sep 17 00:00:00 2001 From: Andriy Kokhan Date: Sun, 18 Feb 2024 11:30:08 +0200 Subject: [PATCH] Added extra checks into ThriftConverter Signed-off-by: Andriy Kokhan --- common/sai_client/sai_thrift_client/sai_thrift_utils.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/common/sai_client/sai_thrift_client/sai_thrift_utils.py b/common/sai_client/sai_thrift_client/sai_thrift_utils.py index 7d682428..b2faf04a 100644 --- a/common/sai_client/sai_thrift_client/sai_thrift_utils.py +++ b/common/sai_client/sai_thrift_client/sai_thrift_utils.py @@ -84,6 +84,7 @@ def convert_value_to_thrift(value, attr_name=None, value_type=None): """ if value_type is None: value_type = ThriftConverter.get_attribute_type(attr_name) + assert value_type, f"Unknown attribute {attr_name}" if value_type in [ 's8', 'u8', 's16', 'u16', 's32', 'u32', 's64', 'u64', 'ptr', @@ -399,6 +400,8 @@ def convert_value_from_thrift(value, attr_name, obj_type=None): sai_thrift_ip_address_t('192.168.0.1'...), "ipaddr" => "192.168.0.1" """ value_type = ThriftConverter.get_attribute_type(attr_name) + assert value_type, f"Unknown attribute {attr_name}" + if value_type in [ 's8', 's16', 'u32', 's64', 'u64', 'ptr', 'mac', 'ipv4', 'ipv6',