Skip to content

Python: clean up exception#2319

Merged
moonbox3 merged 2 commits intomainfrom
alert-autofix-18
Nov 20, 2025
Merged

Python: clean up exception#2319
moonbox3 merged 2 commits intomainfrom
alert-autofix-18

Conversation

@moonbox3
Copy link
Contributor

@moonbox3 moonbox3 commented Nov 19, 2025

We should change the exception handler to log the detailed error and stack trace on the server but return only a generic error message to the API client. Specifically:

  • In the except Exception as e: block, keep the current logging statement (which safely logs full details for diagnostics).
  • Change the response from {"error": str(e)} to a generic message, such as {"error": "An internal error has occurred."} or similar wording.
  • This change is required in the function agent_endpoint inside add_agent_framework_fastapi_endpoint in python/packages/ag-ui/agent_framework_ag_ui/_endpoint.py on or around line 94.

No new methods or imports are required, as logging is already present and providing sufficient diagnostics.


Suggested fixes powered by Copilot Autofix. Review carefully before merging.

…rough an exception

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
@github-actions github-actions bot changed the title Potential fix for code scanning alert no. 18: Information exposure through an exception Python: Potential fix for code scanning alert no. 18: Information exposure through an exception Nov 19, 2025
@moonbox3 moonbox3 changed the title Python: Potential fix for code scanning alert no. 18: Information exposure through an exception Python: clean up exception Nov 19, 2025
@moonbox3 moonbox3 marked this pull request as ready for review November 19, 2025 07:40
Copilot AI review requested due to automatic review settings November 19, 2025 07:40
Copy link
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 improves security by preventing internal error details from being exposed to API clients in the AG-UI agent endpoint.

  • Changed exception handler to return a generic error message instead of exposing internal exception details
  • Detailed error logging is preserved for server-side diagnostics

@markwallace-microsoft
Copy link
Member

Python Test Coverage

Python Test Coverage Report •
FileStmtsMissCoverMissing
packages/ag-ui/agent_framework_ag_ui
   _endpoint.py350100% 
TOTAL15010221485% 

Python Unit Test Overview

Tests Skipped Failures Errors Time
2172 127 💤 0 ❌ 0 🔥 56.446s ⏱️

@moonbox3 moonbox3 added this pull request to the merge queue Nov 20, 2025
Merged via the queue into main with commit 99689ad Nov 20, 2025
23 checks passed
@crickman crickman deleted the alert-autofix-18 branch November 24, 2025 17:09
arisng pushed a commit to arisng/agent-framework that referenced this pull request Feb 2, 2026
* Potential fix for code scanning alert no. 18: Information exposure through an exception

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>

* Fix test

---------

Co-authored-by: Copilot Autofix powered by AI <62310815+github-advanced-security[bot]@users.noreply.github.com>
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.

5 participants