diff --git a/CHANGELOG.rst b/CHANGELOG.rst index c718be8a..67c080cd 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,12 @@ Brewtils Changelog ================== +3.24.2 +------ +TBD + +- Fixed bug where Self Referencing SystemClients did not inspect the command properly for default parameters + 3.24.1 ------ 2/28/2024 diff --git a/brewtils/request_handling.py b/brewtils/request_handling.py index 52e0bc3e..50188e00 100644 --- a/brewtils/request_handling.py +++ b/brewtils/request_handling.py @@ -10,6 +10,7 @@ import six from requests import ConnectionError as RequestsConnectionError +from brewtils.decorators import _parse_method import brewtils.plugin from brewtils.errors import ( BGGivesUpError, @@ -63,12 +64,12 @@ def process_command(self, request): request.has_parent = True # check for kwargs on the target command - for command in self._system.commands: - if command.name == request.command: - for parameter in command.parameters: - if parameter.default: - if parameter.key not in request.parameters: - request.parameters[parameter.key] = parameter.default + command = _parse_method(getattr(brewtils.plugin.CLIENT, request.command, None)) + if command: + for parameter in command.parameters: + if parameter.default: + if parameter.key not in request.parameters: + request.parameters[parameter.key] = parameter.default request.status = "IN_PROGRESS" diff --git a/test/request_handling_test.py b/test/request_handling_test.py index 8d935281..ec3fe315 100644 --- a/test/request_handling_test.py +++ b/test/request_handling_test.py @@ -8,6 +8,7 @@ from mock import ANY, MagicMock, Mock from requests import ConnectionError as RequestsConnectionError +from brewtils.decorators import parameter import brewtils.plugin from brewtils.errors import ( DiscardMessageException, @@ -525,24 +526,12 @@ def command_one(self): def command_two(self): return False + @parameter(key="key", default="value", is_kwarg=True) def command_three(self, **kwargs): return kwargs return ClientTest() - @pytest.fixture - def system_client(self): - return System( - commands=[ - Command(name="command_one"), - Command(name="command_two"), - Command( - name="command_three", - parameters=[Parameter(is_kwarg=True, key="key", default="value")], - ), - ] - ) - @pytest.fixture def resolver_mock(self): def resolve(values, **_): @@ -554,7 +543,7 @@ def resolve(values, **_): return resolver @pytest.fixture - def local_request_processor(self, system_client, client, resolver_mock): + def local_request_processor(self, client, resolver_mock): brewtils.plugin.CLIENT = client def return_input_side_effect(*args, **kwargs): @@ -563,9 +552,7 @@ def return_input_side_effect(*args, **kwargs): _ez_client = Mock() _ez_client.put_request.side_effect = return_input_side_effect - return LocalRequestProcessor( - system=system_client, easy_client=_ez_client, resolver=resolver_mock - ) + return LocalRequestProcessor(easy_client=_ez_client, resolver=resolver_mock) def setup_request_context(self): brewtils.plugin.request_context = threading.local()