From 81da3952555e77254c95abe4a5fa65ae88e427e4 Mon Sep 17 00:00:00 2001 From: eavanvalkenburg Date: Thu, 20 Nov 2025 09:46:12 +0100 Subject: [PATCH 1/2] small fix for logging in declarative --- .../agent_framework_declarative/_models.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/python/packages/declarative/agent_framework_declarative/_models.py b/python/packages/declarative/agent_framework_declarative/_models.py index ecf7ab14ca..187df7faa0 100644 --- a/python/packages/declarative/agent_framework_declarative/_models.py +++ b/python/packages/declarative/agent_framework_declarative/_models.py @@ -30,7 +30,7 @@ def _try_powerfx_eval(value: None) -> None: ... def _try_powerfx_eval(value: str) -> str: ... -def _try_powerfx_eval(value: str | None) -> str | None: +def _try_powerfx_eval(value: str | None, log_value: bool = True) -> str | None: """Check if a value refers to a environment variable and parse it if so.""" if value is None: return value @@ -38,7 +38,7 @@ def _try_powerfx_eval(value: str | None) -> str | None: return value if engine is None: logger.warning( - f"PowerFx engine not available for evaluating value: {value}" + "PowerFx engine not available for evaluating values starting with '='. " "Ensure you are on python 3.13 or less and have the powerfx package installed." "Otherwise replace all powerfx statements in your yaml with strings." ) @@ -46,7 +46,10 @@ def _try_powerfx_eval(value: str | None) -> str | None: try: return engine.eval(value[1:], symbols={"Env": dict(os.environ)}) except Exception as exc: - logger.info("PowerFx evaluation failed for value '%s': %s", value, exc) + if log_value: + logger.info("PowerFx evaluation failed for value '%s': %s", value, exc) + else: + logger.debug("PowerFx evaluation failed for value (first five characters shown) '%s': %s", value[:5], exc) return value @@ -324,7 +327,7 @@ def __init__( ) self.endpoint = _try_powerfx_eval(endpoint) # Support both 'apiKey' and 'key' fields, with 'key' taking precedence if both are provided - self.apiKey = _try_powerfx_eval(key if key else apiKey) + self.apiKey = _try_powerfx_eval(key if key else apiKey, False) class AnonymousConnection(Connection): From 7b0f5985512e56f745bc7e92ac28765501c2c5f4 Mon Sep 17 00:00:00 2001 From: eavanvalkenburg Date: Thu, 20 Nov 2025 10:23:47 +0100 Subject: [PATCH 2/2] fix spaces in string --- .../agent_framework_declarative/_models.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/python/packages/declarative/agent_framework_declarative/_models.py b/python/packages/declarative/agent_framework_declarative/_models.py index 187df7faa0..9ddab17d87 100644 --- a/python/packages/declarative/agent_framework_declarative/_models.py +++ b/python/packages/declarative/agent_framework_declarative/_models.py @@ -23,15 +23,20 @@ @overload -def _try_powerfx_eval(value: None) -> None: ... +def _try_powerfx_eval(value: None, log_value: bool = True) -> None: ... @overload -def _try_powerfx_eval(value: str) -> str: ... +def _try_powerfx_eval(value: str, log_value: bool = True) -> str: ... def _try_powerfx_eval(value: str | None, log_value: bool = True) -> str | None: - """Check if a value refers to a environment variable and parse it if so.""" + """Check if a value refers to a environment variable and parse it if so. + + Args: + value: The value to check. + log_value: Whether to log the full value on error or just a snippet. + """ if value is None: return value if not value.startswith("="): @@ -39,7 +44,7 @@ def _try_powerfx_eval(value: str | None, log_value: bool = True) -> str | None: if engine is None: logger.warning( "PowerFx engine not available for evaluating values starting with '='. " - "Ensure you are on python 3.13 or less and have the powerfx package installed." + "Ensure you are on python 3.13 or less and have the powerfx package installed. " "Otherwise replace all powerfx statements in your yaml with strings." ) return value @@ -47,7 +52,7 @@ def _try_powerfx_eval(value: str | None, log_value: bool = True) -> str | None: return engine.eval(value[1:], symbols={"Env": dict(os.environ)}) except Exception as exc: if log_value: - logger.info("PowerFx evaluation failed for value '%s': %s", value, exc) + logger.debug("PowerFx evaluation failed for value '%s': %s", value, exc) else: logger.debug("PowerFx evaluation failed for value (first five characters shown) '%s': %s", value[:5], exc) return value