-
Notifications
You must be signed in to change notification settings - Fork 423
refactor: enhance error logging, escape HTML and remove unused state update tes… #729
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev-v4
Are you sure you want to change the base?
Conversation
There was a problem hiding this 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 pull request enhances error observability in the backend, attempts to improve security in the frontend configuration endpoint, and performs code cleanup by removing unused state management and dependencies. The changes focus on replacing silent exception handling with debug logging, escaping environment variables for HTML injection prevention, and cleaning up unused imports and peer dependency flags.
Key Changes
- Added debug logging for agent lifecycle exception handling in
lifecycle.pyto improve observability when agent registration, closing, or unregistration fails - Applied HTML escaping to environment variables (
API_URL,ENABLE_AUTH) in the frontend configuration endpoint - Removed unused
raiErrorstate and related code fromHomeInput.tsxcomponent
Reviewed changes
Copilot reviewed 5 out of 7 changed files in this pull request and generated 1 comment.
Show a summary per file
| File | Description |
|---|---|
src/backend/v4/magentic_agents/common/lifecycle.py |
Replaced silent exception handling with debug logging for agent lifecycle events (registration, closing, unregistration) |
src/frontend/frontend_server.py |
Added HTML escaping to environment variables before returning them in the /config endpoint |
src/frontend/src/components/content/HomeInput.tsx |
Removed unused raiError state variable and its associated setter calls |
src/tests/agents/test_human_approval_manager.py |
Removed unused MStep import |
src/tests/agents/test_foundry_integration.py |
Removed unused BingConfig import |
src/frontend/package-lock.json |
Removed "peer": true flags from multiple dependencies and minor version updates |
package-lock.json |
Added new empty root-level package-lock.json file |
Files not reviewed (1)
- src/frontend/package-lock.json: Language not supported
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
src/frontend/frontend_server.py
Outdated
| # Escape the values for safe inclusion in HTML | ||
| escaped_backend_url = html.escape(backend_url) | ||
| escaped_auth_enabled = html.escape(auth_enabled) | ||
|
|
||
| config = { | ||
| "API_URL": backend_url, | ||
| "ENABLE_AUTH": auth_enabled, | ||
| "API_URL": escaped_backend_url, | ||
| "ENABLE_AUTH": escaped_auth_enabled, |
Copilot
AI
Dec 19, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
HTML escaping is not necessary for JSON API responses. The /config endpoint returns a JSON dictionary, not HTML content. HTML escaping is intended for values that will be embedded in HTML templates, but FastAPI's JSONResponse (the default for dict returns) already handles proper JSON encoding. Using html.escape() here will double-escape special characters when the values are used in the frontend JavaScript, potentially breaking URLs or configuration values that contain HTML special characters like &.
…ve unused error card import in HomeInput component
Purpose
This pull request introduces several improvements across the backend and frontend codebases, focusing on better error logging, enhanced security for frontend configuration, and minor code and dependency cleanups. The most significant changes include replacing silent exception handling with debug logging for agent lifecycle events, escaping environment variables before injecting them into the frontend, and removing unnecessary state management and peer dependency flags.
Backend Improvements:
lifecycle.py, replacing silent exception swallowing with informative log messages when agent registration, closing, or unregistration fails. This improves observability and troubleshooting for agent state transitions. [1] [2] [3]Frontend Improvements:
API_URL,ENABLE_AUTH) before injecting them into the frontend config to prevent potential HTML injection vulnerabilities.raiErrorstate and related code fromHomeInput.tsx, simplifying the component's state management. [1] [2] [3] [4]Dependency and Test Cleanups:
"peer": trueflag from multiple dependencies inpackage-lock.jsonto clean up the dependency tree and avoid unnecessary peer dependency warnings. [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22] [23]test_foundry_integration.pyandtest_human_approval_manager.py. [1] [2]Does this introduce a breaking change?
How to Test
What to Check
GP Testing