Python: improve logging in declarative code #3573
Open
+3
−3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Potential fix for https://github.com/microsoft/agent-framework/security/code-scanning/49
In general, to fix clear‑text logging of sensitive information, remove or mask sensitive values from log messages. Logs should contain enough context (such as an identifier or generic description) to debug issues without exposing secrets (passwords, API keys, tokens, etc.).
In this specific case, the problem is the two
logger.debugcalls in_try_powerfx_evalthat interpolatevalue(orvalue[:5]) directly into the log message. The best fix while preserving functionality is:exc) and note that some value failed evaluation.valueentirely from logs, or replace it with a constant placeholder such as'<redacted>'.log_valueflag only to control the presence of any value-specific hint vs. a more generic message, but no longer log actual characters of the value.Given we must not assume any broader project context or modify other files, the change will be localized to
_try_powerfx_evalinpython/packages/declarative/agent_framework_declarative/_models.py. We will replace:with something like:
or equivalent f-strings that do not include
value. This avoids logging any part of the possibly sensitive data while still preserving error information via the exception.No new imports or additional helper methods are required.
Suggested fixes powered by Copilot Autofix. Review carefully before merging.