Skip to content

Commit

Permalink
Added extra checks into ThriftConverter (#235)
Browse files Browse the repository at this point in the history
Signed-off-by: Andriy Kokhan <andriy.kokhan@plvision.eu>
  • Loading branch information
andriy-kokhan authored Feb 18, 2024
1 parent 95edf36 commit ade30b9
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions common/sai_client/sai_thrift_client/sai_thrift_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand Down Expand Up @@ -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',
Expand Down

0 comments on commit ade30b9

Please sign in to comment.