Complete JSONC parsing fix for MCPConfig.UnmarshalJSON method#388
Complete JSONC parsing fix for MCPConfig.UnmarshalJSON method#388
Conversation
This completes the JSONC parsing fix started in PR #386. While the loadConfig function was updated to use jsonc.Unmarshal, the custom MCPConfig.UnmarshalJSON method still used json.Unmarshal in three locations, causing the 'invalid character \'/\' looking for beginning of value' error to persist when parsing VS Code settings with comments. Updated all three json.Unmarshal calls to jsonc.Unmarshal: - Line 69: Unmarshaling into auxiliary struct - Line 74: Unmarshaling into map for extra fields - Line 85: Unmarshaling individual values in extra fields This ensures consistent JSONC parsing throughout the MCP config system. Co-Authored-By: Rick Blalock <rickblalock@mac.com>
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
|
Important Review skippedBot user detected. To trigger a single review, invoke the You can disable this status message by setting the 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Join our Discord community for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
jhaynie
left a comment
There was a problem hiding this comment.
i'm still seeing this error:
failed to load MCP config for Amp (Cursor): unexpected end of JSON input
I edited the settings.json for cursor and added /* test */ to the top of the JSON inline and it errors.
can you write a test cases to verify that jsonc supports comments?
…hensive tests - Fix remaining json.Unmarshal call in MarshalJSON method to use jsonc.Unmarshal - Add comprehensive test cases for JSONC comment support including: - User's exact case: /* test */ comment at top of JSON - Single line comments (//) - Multi-line comments (/* */) - Mixed comment types - Empty JSON with comments - Comments at end of JSON - Complete load-save cycle testing - Cursor settings with comments testing This completes the JSONC parsing implementation throughout the entire MCP config system, resolving the persistent 'unexpected end of JSON input' error when parsing VS Code/Cursor settings files containing comments. Co-Authored-By: Rick Blalock <rickblalock@mac.com>
Complete JSONC Parsing Fix for MCP Config
Problem
While PR #386 fixed the
loadConfigfunction to use JSONC parsing, the error "invalid character '/' looking for beginning of value" persisted when parsing VS Code settings with comments. Investigation revealed that the customMCPConfig.UnmarshalJSONmethod still used standard JSON parsing in three locations.Root Cause
The
MCPConfigstruct has a customUnmarshalJSONmethod that gets called during unmarshaling. This method still usedjson.Unmarshalin three places:When
jsonc.Unmarshalcalled this custom method, it would fail on comments because the custom method used standard JSON parsing internally.Solution
Updated all three
json.Unmarshalcalls tojsonc.Unmarshalin theMCPConfig.UnmarshalJSONmethod to maintain consistency with theloadConfigfunction and provide complete JSONC parsing support throughout the MCP config system.Changes
json.Unmarshal(data, &aux)→jsonc.Unmarshal(data, &aux)json.Unmarshal(data, &all)→jsonc.Unmarshal(data, &all)json.Unmarshal(v, &val)→jsonc.Unmarshal(v, &val)Testing
go build -v ./...go fmt ./...andgo mod tidyrun)Link to Devin run
https://app.devin.ai/sessions/7144f22861c54068a3f3690e22c3bf60
Requested by: jhaynie@agentuity.com
This completes the JSONC parsing fix for the Agentuity CLI MCP config system, ensuring that VS Code settings with comments can be parsed successfully throughout the entire parsing pipeline.