fix: fix other ICM issue and added local setup steps for mcp server - #1162
Merged
Merged
Conversation
Coverage Report •
|
||||||||||||||||||||||||||||||||||||||||
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The router currently raises a 500 for valid plans due to invalid session_id access, with additional contract and test-coverage issues.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 1
Open (2)
What changed in this PR
This PR hardens agent-message authorization and improves MCP server local setup and configuration.
Changes:
- Validates plan ownership and enforces the authenticated user ID.
- Adds authorization and identity regression tests.
- Adds environment configuration, credential selection, and setup documentation.
- Follow-up required for the router’s invalid
Plan.session_idaccess, request-status mismatch, documentation, and targeted test coverage.
| File | Summary |
|---|---|
src/tests/backend/services/test_plan_service.py |
Tests authenticated user ID enforcement. |
src/tests/backend/api/test_router.py |
Tests authorization failures; ownership assertion should be strengthened. |
src/mcp_server/services/image_service.py |
Selects credentials by environment; branch coverage should be added. |
src/mcp_server/config/settings.py |
Adds app_env configuration. |
src/mcp_server/.env.example |
Adds environment variables. |
src/backend/services/plan_service.py |
Forces authenticated user IDs. |
src/backend/api/router.py |
Adds plan validation and ownership checks; contains a critical invalid attribute access and contract/documentation mismatches. |
docs/LocalDevelopmentSetup.md |
Expands MCP setup instructions. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Roopan-Microsoft
approved these changes
Sep 25, 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.


Purpose
This pull request introduces important security improvements to the
/api/v4/agent_messageendpoint, ensuring that agent messages cannot be injected across users and that only the authenticated user can persist messages for their own plans. Additionally, it improves local development setup instructions, environment variable handling, and test coverage for these changes.Security and Authorization Improvements:
/api/v4/agent_messageendpoint now requires aplan_idand verifies that the plan belongs to the authenticated user before processing messages, preventing cross-user message injection. If the plan does not exist for the user, a 404 is returned, and ifplan_idis missing, a 400 is returned. (src/backend/api/router.py, src/backend/api/router.pyL896-L911)build_agent_message_from_agent_message_responsefunction always uses the authenticated user'suser_id, ignoring anyuser_idpresent in the payload, further preventing cross-user data injection. (src/backend/services/plan_service.py, src/backend/services/plan_service.pyL98-R102)Testing Enhancements:
user_idis always enforced. (src/tests/backend/api/test_router.py, [1];src/tests/backend/services/test_plan_service.py, [2]Local Development and Configuration Updates:
.envfile creation, Azure configuration, and local overrides. (docs/LocalDevelopmentSetup.md, [1] [2].env.exampleand introducedapp_envto configuration, allowing for environment-specific behavior. (src/mcp_server/.env.example, [1];src/mcp_server/config/settings.py, [2]image_service.pyto use the newapp_envconfiguration. (src/mcp_server/services/image_service.py, src/mcp_server/services/image_service.pyL33-R35)Does this introduce a breaking change?
How to Test
What to Check
Verify that the following are valid
Other Information