Python: fix: add logging to silent exception handlers (ag-ui + purview)#5681
Open
vystartasv wants to merge 1 commit intomicrosoft:mainfrom
Open
Python: fix: add logging to silent exception handlers (ag-ui + purview)#5681vystartasv wants to merge 1 commit intomicrosoft:mainfrom
vystartasv wants to merge 1 commit intomicrosoft:mainfrom
Conversation
3 bare except Exception blocks now log failures: - _workflow_run.py: content coercion failures (2, debug level) - _models.py: Purview enum conversion failure (warning level) Uses existing module-level loggers already defined in each file.
Contributor
There was a problem hiding this comment.
Pull request overview
This PR adds diagnostic logging to previously silent exception handlers in the Python AG-UI workflow stream coercion code and Purview model deserialization helpers, improving debuggability without changing return behavior (still returning None on conversion failures).
Changes:
- Add
logger.debug(..., exc_info=True)when AG-UIContent.from_dict(...)coercion fails (candidate + message content paths). - Add
logger.warning(...)when Purview int→enum flag conversion fails during deserialization.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| python/packages/purview/agent_framework_purview/_models.py | Adds a warning log when int→flag-enum conversion fails in deserialize_flag. |
| python/packages/ag-ui/agent_framework_ag_ui/_workflow_run.py | Adds debug logs (with stack traces) for best-effort content coercion failures. |
Comment on lines
89
to
93
| try: | ||
| return enum_cls(value) | ||
| except Exception: | ||
| logger.warning("Failed to convert int %s to %s", value, enum_cls.__name__) | ||
| return None |
Comment on lines
91
to
+92
| except Exception: | ||
| logger.warning("Failed to convert int %s to %s", value, enum_cls.__name__) |
Author
|
@microsoft-github-policy-service agree |
lokitoth
approved these changes
May 7, 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.
Problem
3
except Exceptionblocks silently swallow failures with no diagnostic output:_workflow_run.py_coerce_candidate_content_workflow_run.py_coerce_message_content_models.pyFix
Each catch now logs at the appropriate level using the existing module-level
logger = logging.getLogger(__name__):logger.debug()(best-effort conversion, not an error)logger.warning()(indicates malformed data)Changes
Noneon failure