Skip to content

Python: fix: add logging to silent exception handlers (ag-ui + purview)#5681

Open
vystartasv wants to merge 1 commit intomicrosoft:mainfrom
vystartasv:fix/silent-exceptions
Open

Python: fix: add logging to silent exception handlers (ag-ui + purview)#5681
vystartasv wants to merge 1 commit intomicrosoft:mainfrom
vystartasv:fix/silent-exceptions

Conversation

@vystartasv
Copy link
Copy Markdown

Problem

3 except Exception blocks silently swallow failures with no diagnostic output:

File Location What fails silently
_workflow_run.py _coerce_candidate_content AG-UI content coercion fails
_workflow_run.py _coerce_message_content Message content coercion fails
_models.py enum conversion Purview int→enum conversion fails

Fix

Each catch now logs at the appropriate level using the existing module-level logger = logging.getLogger(__name__):

  • Content coercion failures → logger.debug() (best-effort conversion, not an error)
  • Enum conversion failure → logger.warning() (indicates malformed data)

Changes

  • 2 files, 3 lines added
  • No behavioral changes — all functions still return None on failure

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.
Copilot AI review requested due to automatic review settings May 6, 2026 19:23
@moonbox3 moonbox3 added the python label May 6, 2026
@github-actions github-actions Bot changed the title fix: add logging to silent exception handlers (ag-ui + purview) Python: fix: add logging to silent exception handlers (ag-ui + purview) May 6, 2026
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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-UI Content.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__)
@vystartasv
Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants