Python: improve logging in declarative code#3573
Merged
Conversation
…ensitive information Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
Member
Contributor
There was a problem hiding this comment.
Pull request overview
This PR addresses a security vulnerability where sensitive information (such as API keys) could be logged in clear text during PowerFx evaluation failures. The fix redacts the actual values from log messages while preserving exception information for debugging.
Changes:
- Updated the
log_valueparameter documentation to reflect its new purpose of controlling additional context rather than logging the actual value - Replaced direct value logging in error messages with generic placeholders that don't expose sensitive data
- Maintained differentiation between regular fields and sensitive fields through distinct log messages
markwallace-microsoft
approved these changes
Feb 3, 2026
eavanvalkenburg
approved these changes
Feb 3, 2026
dmytrostruk
approved these changes
Feb 4, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.