diff --git a/src/sonic-bgpcfgd/staticroutebfd/main.py b/src/sonic-bgpcfgd/staticroutebfd/main.py index 268dbd3c1669..89f10f2dca5a 100644 --- a/src/sonic-bgpcfgd/staticroutebfd/main.py +++ b/src/sonic-bgpcfgd/staticroutebfd/main.py @@ -376,7 +376,7 @@ def static_route_set_handler(self, key, data): valid, is_ipv4, ip = check_ip(ip_prefix) if not valid: - log_err("invalid ip prefix for static route: ", key) + log_err("invalid ip prefix for static route: '%s'"%(key)) return True #use lower case if there is letter in IPv6 address string diff --git a/src/sonic-bgpcfgd/tests/test_static_rt_bfd.py b/src/sonic-bgpcfgd/tests/test_static_rt_bfd.py index f9b6139244b8..5198e50eae5c 100644 --- a/src/sonic-bgpcfgd/tests/test_static_rt_bfd.py +++ b/src/sonic-bgpcfgd/tests/test_static_rt_bfd.py @@ -171,6 +171,23 @@ def test_set_del_ipv6(): {'del_default:2603:10e2:400::4/128': { }} ) +@patch('staticroutebfd.main.log_err') +def test_invalid_key(mocked_log_err): + dut = constructor() + intf_setup(dut) + + set_del_test(dut, "srt", + "SET", + ("2.2.2/24", { + "bfd": "true", + "nexthop": "192.168.1.2 , 192.168.2.2, 192.168.3.2", + "ifname": "if1, if2, if3", + }), + {}, + {} + ) + mocked_log_err.assert_called_with("invalid ip prefix for static route: '2.2.2/24'") + def test_set_del(): dut = constructor() intf_setup(dut)