fix: show MCP config file paths correctly in error messages#2785
Draft
laileni-aws wants to merge 1 commit into
Draft
fix: show MCP config file paths correctly in error messages#2785laileni-aws wants to merge 1 commit into
laileni-aws wants to merge 1 commit into
Conversation
MCP config load errors embed the file path and are rendered as markdown in the UI. For Windows paths, a segment such as "\.aws" had its backslash stripped by the markdown parser, so the path was displayed incorrectly (e.g. C:\Users\me.aws\... instead of C:\Users\me\.aws\...), which misled users into thinking the path was wrong. Wrap the file path in a code span (backticks) in the config-load error messages and in the 'File: <path>' prefix so paths render verbatim. Updates and adds unit tests, including a Windows path with a ".aws" segment.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #2785 +/- ##
==========================================
- Coverage 60.20% 60.16% -0.05%
==========================================
Files 281 281
Lines 71191 71194 +3
Branches 4575 4560 -15
==========================================
- Hits 42861 42832 -29
- Misses 28241 28274 +33
+ Partials 89 88 -1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Problem
When MCP config loading fails, the error is shown to the user (in the MCP servers view / status), and the message embeds the config file path. That message is rendered as markdown, so a Windows path segment such as
\.awshas its backslash stripped (\.is a markdown escape). The path is therefore displayed incorrectly — e.g.C:\Users\me\.aws\amazonq\mcp.jsonshows asC:\Users\me.aws\amazonq\mcp.json.This misleads users into thinking Amazon Q is looking at the wrong path (a reported case: a user concluded "it's a path issue, the file doesn't exist" when the path was actually correct and their
mcp.jsonwas simply empty — "Unexpected end of JSON input").Fix
Wrap the file path in a markdown code span (backticks) so it renders verbatim, including backslashes:
server/aws-lsp-codewhisperer/src/language-server/agenticChat/tools/mcp/mcpUtils.ts: the "Failed to read", "Invalid JSON", and "missing/invalidmcpServers" messages now wrap the path as`<path>`.mcpManager.ts(getConfigLoadErrors): theFile: <path>prefix now wraps the path/server key asFile: `<path>`.Testing
mcpManager.test.tsassertions for the newFile:`…``` format.\.awssegment is wrapped in a code span (so its backslash survives markdown rendering).mcpManager.test.ts+mcpUtils.test.ts): 112 passing.prettier --checkpasses;eslintreports no new issues (only pre-existing warnings unrelated to this change).Notes
mcp.json) are unchanged and still reported.