Skip to content

Commit d2fd83c

Browse files
committed
feat: Add error handling for masking-show command failures
1 parent ec54e3a commit d2fd83c

File tree

2 files changed

+16
-3
lines changed

2 files changed

+16
-3
lines changed

lib/live_cluster/client/node.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3389,11 +3389,14 @@ async def info_masking_list_rules(self, namespace=None, set_=None):
33893389
if set_ is not None:
33903390
masking_show_req += "set={};".format(set_)
33913391

3392+
resp = await self._info(masking_show_req)
3393+
3394+
if resp.startswith("ERROR"):
3395+
raise ASInfoResponseError("Failed to list masking rules", resp)
3396+
33923397
return [
33933398
client_util.info_to_dict(v, ";")
3394-
for v in client_util.info_to_list(
3395-
await self._info(masking_show_req), delimiter=":"
3396-
)
3399+
for v in client_util.info_to_list(resp, delimiter=":")
33973400
if v != ""
33983401
]
33993402

test/unit/live_cluster/client/test_node.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4597,6 +4597,16 @@ async def test_info_masking_list_rules_empty_response(self):
45974597

45984598
self.assertEqual(result, [])
45994599

4600+
async def test_info_masking_list_rules_error(self):
4601+
"""Test masking rules listing with ERROR response"""
4602+
self.info_mock.return_value = "ERROR::masking not supported"
4603+
4604+
result = await self.node.info_masking_list_rules()
4605+
4606+
self.assertIsInstance(result, ASInfoResponseError)
4607+
self.assertEqual(result.message, "Failed to list masking rules")
4608+
self.assertEqual(result.response, "masking not supported")
4609+
46004610

46014611
class SyscmdTest(unittest.TestCase):
46024612
def setUp(self) -> None:

0 commit comments

Comments
 (0)