fix: resolved ICM issue and added local setup steps - #1161
Closed
Dhruvkumar-Microsoft wants to merge 1 commit into
Closed
Dhruvkumar-Microsoft wants to merge 1 commit into
Dhruvkumar-Microsoft wants to merge 1 commit into
Conversation
Dhruvkumar-Microsoft
requested
a lite review from Copilot
and removed request for
Avijit-Microsoft,
Francia Riesco (Fr4nc3),
Prajwal-Microsoft,
Roopan-Microsoft,
Vinay Sharma (Vinay-Microsoft),
Anish Arora (aniaroramsft),
dgp10801,
nchandhi and
Todd Herman (toherman-msft)
September 24, 2026 11:29
Coverage Report •
|
||||||||||||||||||||||||||||||||||||||||
Contributor
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
Address missing-plan_id status handling, document new API responses, and add credential-selection tests.
Get a fresh assessment by requesting another Copilot review.
Review effort: Lite
Findings: 2
Open (3)
What changed in this PR
Strengthens agent-message authorization and improves local MCP setup and configuration.
Changes:
- Validates plan ownership and enforces authenticated user IDs.
- Adds authorization and regression tests.
- Adds environment configuration, credential selection, and setup documentation.
| File | Summary |
|---|---|
src/tests/backend/services/test_plan_service.py |
Tests authenticated user ID enforcement. |
src/tests/backend/api/test_router.py |
Tests plan authorization failures. |
src/mcp_server/services/image_service.py |
Selects credentials by environment. |
src/mcp_server/config/settings.py |
Adds app_env configuration. |
src/mcp_server/.env.example |
Adds Azure and environment settings. |
src/backend/services/plan_service.py |
Uses the authenticated user ID. |
src/backend/api/router.py |
Adds plan ownership validation and response handling. |
docs/LocalDevelopmentSetup.md |
Expands local MCP setup instructions. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Comment on lines
+899
to
+900
| if not agent_message.plan_id: | ||
| raise HTTPException(status_code=400, detail="plan_id is required") |
Comment on lines
+33
to
+35
| app_env = (config.app_env or os.environ.get("APP_ENV") or "prod").lower() | ||
| if app_env == "dev": | ||
| return DefaultAzureCredential(require_envvar=True) | ||
| return DefaultAzureCredential() |
Comment on lines
+896
to
+900
| # Authorization: require plan_id and verify the plan belongs to the | ||
| # authenticated user before persisting any agent message for it. This | ||
| # prevents cross-user message injection through /api/v4/agent_message. | ||
| if not agent_message.plan_id: | ||
| raise HTTPException(status_code=400, detail="plan_id is required") |
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 strengthens security around agent message handling, improves local development setup instructions, and enhances test coverage. The main focus is on ensuring that agent messages cannot be injected or manipulated across users by strictly validating
plan_idownership and always using the authenticated user's ID. Additional improvements include environment variable handling and documentation updates.Security and Authorization Improvements
/api/v4/agent_messageendpoint now requires aplan_idand verifies that the plan belongs to the authenticated user before accepting agent messages, preventing cross-user message injection. If the plan is missing or not owned by the user, the endpoint returns appropriate error codes (400 for missing, 404 for not found/owned).build_agent_message_from_agent_message_responsefunction is updated to always use the authenticated user's ID, ignoring any user ID supplied in the payload, further preventing unauthorized message assignment.Testing Enhancements
plan_idis handled with a 400 error, and that the service method is not called in these cases.Developer Experience and Configuration
.envfile and connecting to Azure resources. [1] [2]APP_ENVand other Azure-related settings.app_env, and environment-based credential selection inimage_service.pyis improved for easier local development. [1] [2]Does this introduce a breaking change?
How to Test
What to Check
Verify that the following are valid
Other Information