From 81bc27a4352b1f1545f067ffc34488d168f80cc9 Mon Sep 17 00:00:00 2001 From: TheBurchLog <5104941+TheBurchLog@users.noreply.github.com> Date: Fri, 10 Apr 2026 17:46:30 +0000 Subject: [PATCH 1/6] System Client support for defining choice validation --- brewtils/rest/system_client.py | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/brewtils/rest/system_client.py b/brewtils/rest/system_client.py index 9cad0378..47c939d7 100644 --- a/brewtils/rest/system_client.py +++ b/brewtils/rest/system_client.py @@ -67,6 +67,11 @@ class SystemClient(object): to each namespace to help load balance the requests. It will rotate per Request to the target system. + choice_validation_enabled: + Flag controlling whether choice validation is enabled when creating requests. Valid options are + True, False, and None. True will enable full choice validation, False will disable it, and None + will use the default behavior. Default is None for System Clients. + Loading the System: The System definition is lazily loaded, so nothing happens until the first attempt to send a Request. At that point the SystemClient will query Beer-garden @@ -179,7 +184,7 @@ class SystemClient(object): Only has an effect when blocking=False. raise_on_error (bool): Flag controlling whether created Requests that complete with an ERROR state should raise an exception - + choice_validation_enabled (bool): Flag controlling whether choice validation is enabled when creating requests. bg_host (str): Beer-garden hostname bg_port (int): Beer-garden port bg_url_prefix (str): URL path that will be used as a prefix when communicating @@ -267,6 +272,7 @@ def __init__(self, *args, **kwargs): self._max_delay = kwargs.get("max_delay", 30) self._blocking = kwargs.get("blocking", True) self._raise_on_error = kwargs.get("raise_on_error", False) + self._choice_validation_enabled = kwargs.get("choice_validation_enabled", None) # This is for Python 3.4 compatibility - max_workers MUST be non-None # in that version. This logic is what was added in Python 3.5 @@ -415,6 +421,9 @@ def send_bg_request(self, *args, **kwargs): raise_on_error = kwargs.pop("_raise_on_error", self._raise_on_error) blocking = kwargs.pop("_blocking", self._blocking) timeout = kwargs.pop("_timeout", self._timeout) + choice_validation_enabled = kwargs.pop( + "_choice_validation_enabled", self._choice_validation_enabled + ) # If the request fails validation and the version constraint allows, # check for a new version and retry @@ -423,7 +432,10 @@ def send_bg_request(self, *args, **kwargs): if not self.target_self: request = self._easy_client.create_request( - request, blocking=blocking, timeout=timeout + request, + blocking=blocking, + timeout=timeout, + choice_validation_enabled=choice_validation_enabled, ) except ValidationError: From b5b8499633ee94b26d1185e78d6da39db40325b1 Mon Sep 17 00:00:00 2001 From: TheBurchLog <5104941+TheBurchLog@users.noreply.github.com> Date: Fri, 10 Apr 2026 17:57:16 +0000 Subject: [PATCH 2/6] Change Log --- CHANGELOG.rst | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/CHANGELOG.rst b/CHANGELOG.rst index d74a2781..7f9ea6ca 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -1,6 +1,14 @@ Brewtils Changelog ================== +TBD +------ +TBD + +- Added support for SystemClient to define choice_validation_enabled flag during initialization or command execution. + Default behavior is to skip choice validation if a parent request is present. (#585) + Examples: SystemClient(..., choice_validation_enabled=True) or SystemClient().call_command(..., _choice_validation_enabled=True) + 3.32.0 ------ 3/4/26 From 42974f562e90e1ba8e4a01c70949b39566c75156 Mon Sep 17 00:00:00 2001 From: TheBurchLog <5104941+TheBurchLog@users.noreply.github.com> Date: Mon, 20 Apr 2026 15:00:44 +0000 Subject: [PATCH 3/6] formatting --- test/decorators_test.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/test/decorators_test.py b/test/decorators_test.py index 8285cab8..ecaa7c77 100644 --- a/test/decorators_test.py +++ b/test/decorators_test.py @@ -1385,11 +1385,13 @@ def test_positional_only(self): import textwrap exec_locals = {} - class_dec = textwrap.dedent(""" + class_dec = textwrap.dedent( + """ class Tester(object): def c(self, foo, /): pass - """) + """ + ) # Black doesn't handle this well - because we run in 2.7 mode it wants to # put a space after exec, but then it complains about the space after exec. From d9a2d986713f3ead5157fc062773a28858bc1106 Mon Sep 17 00:00:00 2001 From: TheBurchLog <5104941+TheBurchLog@users.noreply.github.com> Date: Mon, 20 Apr 2026 15:03:48 +0000 Subject: [PATCH 4/6] more formatting --- brewtils/rest/system_client.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/brewtils/rest/system_client.py b/brewtils/rest/system_client.py index 38b83c06..470a5d82 100644 --- a/brewtils/rest/system_client.py +++ b/brewtils/rest/system_client.py @@ -68,9 +68,10 @@ class SystemClient(object): Request to the target system. choice_validation_enabled: - Flag controlling whether choice validation is enabled when creating requests. Valid options are - True, False, and None. True will enable full choice validation, False will disable it, and None - will use the default behavior. Default is None for System Clients. + Flag controlling whether choice validation is enabled when creating + requests. Valid options are True, False, and None. True will enable + full choice validation, False will disable it, and None will use the + default behavior. Default is None for System Clients. Loading the System: The System definition is lazily loaded, so nothing happens until the first From 8a2df511487d87148bbbf802a3b02e3d5713bf07 Mon Sep 17 00:00:00 2001 From: TheBurchLog <5104941+TheBurchLog@users.noreply.github.com> Date: Mon, 20 Apr 2026 15:05:15 +0000 Subject: [PATCH 5/6] Formatting --- brewtils/rest/system_client.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/brewtils/rest/system_client.py b/brewtils/rest/system_client.py index 470a5d82..f56b0e49 100644 --- a/brewtils/rest/system_client.py +++ b/brewtils/rest/system_client.py @@ -185,7 +185,8 @@ class SystemClient(object): Only has an effect when blocking=False. raise_on_error (bool): Flag controlling whether created Requests that complete with an ERROR state should raise an exception - choice_validation_enabled (bool): Flag controlling whether choice validation is enabled when creating requests. + choice_validation_enabled (bool): Flag controlling whether choice validation is + enabled when creating requests. bg_host (str): Beer-garden hostname bg_port (int): Beer-garden port bg_url_prefix (str): URL path that will be used as a prefix when communicating From 86fd57a9a8f1beee168e3d060af5b5afb834b244 Mon Sep 17 00:00:00 2001 From: TheBurchLog <5104941+TheBurchLog@users.noreply.github.com> Date: Mon, 20 Apr 2026 15:20:18 +0000 Subject: [PATCH 6/6] formatting --- test/decorators_test.py | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/test/decorators_test.py b/test/decorators_test.py index ecaa7c77..8285cab8 100644 --- a/test/decorators_test.py +++ b/test/decorators_test.py @@ -1385,13 +1385,11 @@ def test_positional_only(self): import textwrap exec_locals = {} - class_dec = textwrap.dedent( - """ + class_dec = textwrap.dedent(""" class Tester(object): def c(self, foo, /): pass - """ - ) + """) # Black doesn't handle this well - because we run in 2.7 mode it wants to # put a space after exec, but then it complains about the space after exec.