From d12829c6aa75e7e7dbb64b62d812b52ab70019ed Mon Sep 17 00:00:00 2001 From: Josh VanDeraa Date: Wed, 18 Aug 2021 16:54:28 -0500 Subject: [PATCH 1/6] Provides a response with empty choices --- nautobot_chatops/workers/nautobot.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/nautobot_chatops/workers/nautobot.py b/nautobot_chatops/workers/nautobot.py index 9a52ef50..a2844eee 100644 --- a/nautobot_chatops/workers/nautobot.py +++ b/nautobot_chatops/workers/nautobot.py @@ -388,6 +388,14 @@ def get_interface_connections(dispatcher, filter_type, filter_value_1, filter_va f'Unknown filter type "{filter_type}"', ) # command did not run to completion and therefore should not be logged + # Check on empty choice list, send an error back + if not choices: + dispatcher.send_markdown( + message=f"Unable to apply filter on '{filter_type}', please validate that data is present for a filter", + ephemeral=True + ) + return False + if filter_type != "device": dispatcher.prompt_from_menu( f"nautobot get-interface-connections {filter_type}", From 069723f30f3f6d0ef431739abd06d992a8282e16 Mon Sep 17 00:00:00 2001 From: Josh VanDeraa Date: Thu, 19 Aug 2021 08:30:12 -0500 Subject: [PATCH 2/6] Update nautobot_chatops/workers/nautobot.py Co-authored-by: Glenn Matthews --- nautobot_chatops/workers/nautobot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nautobot_chatops/workers/nautobot.py b/nautobot_chatops/workers/nautobot.py index a2844eee..71d2afbf 100644 --- a/nautobot_chatops/workers/nautobot.py +++ b/nautobot_chatops/workers/nautobot.py @@ -391,7 +391,7 @@ def get_interface_connections(dispatcher, filter_type, filter_value_1, filter_va # Check on empty choice list, send an error back if not choices: dispatcher.send_markdown( - message=f"Unable to apply filter on '{filter_type}', please validate that data is present for a filter", + message=f"Unable to filter by '{filter_type}', as it appears there is no corresponding data available", ephemeral=True ) return False From 96106cdbf55e276092e78fa39efcdce36a1621a8 Mon Sep 17 00:00:00 2001 From: Josh VanDeraa Date: Thu, 19 Aug 2021 08:31:41 -0500 Subject: [PATCH 3/6] Uses Status Failed message --- nautobot_chatops/workers/nautobot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nautobot_chatops/workers/nautobot.py b/nautobot_chatops/workers/nautobot.py index a2844eee..98a46d36 100644 --- a/nautobot_chatops/workers/nautobot.py +++ b/nautobot_chatops/workers/nautobot.py @@ -394,7 +394,7 @@ def get_interface_connections(dispatcher, filter_type, filter_value_1, filter_va message=f"Unable to apply filter on '{filter_type}', please validate that data is present for a filter", ephemeral=True ) - return False + return CommandStatusChoices.STATUS_FAILED if filter_type != "device": dispatcher.prompt_from_menu( From 8681e4308454c93b71a172631ac46652b3165383 Mon Sep 17 00:00:00 2001 From: Josh VanDeraa Date: Thu, 19 Aug 2021 08:46:44 -0500 Subject: [PATCH 4/6] Uses Status Failed message --- nautobot_chatops/workers/nautobot.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nautobot_chatops/workers/nautobot.py b/nautobot_chatops/workers/nautobot.py index e04b57af..31581643 100644 --- a/nautobot_chatops/workers/nautobot.py +++ b/nautobot_chatops/workers/nautobot.py @@ -392,7 +392,7 @@ def get_interface_connections(dispatcher, filter_type, filter_value_1, filter_va if not choices: dispatcher.send_markdown( message=f"Unable to filter by '{filter_type}', as it appears there is no corresponding data available", - ephemeral=True + ephemeral=True, ) return CommandStatusChoices.STATUS_FAILED From 622880d1fec4b9f53b9e14d9b19368e7cbf33a9b Mon Sep 17 00:00:00 2001 From: Josh VanDeraa Date: Thu, 19 Aug 2021 09:00:49 -0500 Subject: [PATCH 5/6] Update nautobot_chatops/workers/nautobot.py Co-authored-by: Glenn Matthews --- nautobot_chatops/workers/nautobot.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/nautobot_chatops/workers/nautobot.py b/nautobot_chatops/workers/nautobot.py index 31581643..eda797b4 100644 --- a/nautobot_chatops/workers/nautobot.py +++ b/nautobot_chatops/workers/nautobot.py @@ -394,7 +394,10 @@ def get_interface_connections(dispatcher, filter_type, filter_value_1, filter_va message=f"Unable to filter by '{filter_type}', as it appears there is no corresponding data available", ephemeral=True, ) - return CommandStatusChoices.STATUS_FAILED + return ( + CommandStatusChoices.STATUS_FAILED, + f'No choices found when filtering by "{filter_type}"', + ) if filter_type != "device": dispatcher.prompt_from_menu( From 64f0303b47f72a890a7d38a3c9e66bfbfdb2e142 Mon Sep 17 00:00:00 2001 From: Josh VanDeraa Date: Thu, 19 Aug 2021 09:16:47 -0500 Subject: [PATCH 6/6] Fixes pylint length issue --- pyproject.toml | 1 + 1 file changed, 1 insertion(+) diff --git a/pyproject.toml b/pyproject.toml index 4f369ccc..46c05ac0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -67,6 +67,7 @@ load-plugins="pylint_django" disable=""", django-not-configured, too-few-public-methods, + too-many-lines, """ [tool.pylint.miscellaneous]