Skip to content

FLOW-1577: Fix double JSON.parse error in MCP tool return message parsing - (Jira Coding Agent) - #1894

Open
ccallcottstevens wants to merge 1 commit into
mainfrom
FLOW-1577-atlascode-syntaxerror-invalid-json-00467
Open

FLOW-1577: Fix double JSON.parse error in MCP tool return message parsing - (Jira Coding Agent)#1894
ccallcottstevens wants to merge 1 commit into
mainfrom
FLOW-1577-atlascode-syntaxerror-invalid-json-00467

Conversation

@ccallcottstevens

@ccallcottstevens ccallcottstevens commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

Fix JSON parsing error for MCP tool returns caused by double-stringified payloads

This PR addresses a SyntaxError occurring when parsing MCP tool return messages due to the backend accidentally double-stringifying the JSON payload in toolCallMessage.args. The fix adds defensive parsing logic to detect and correctly parse double-stringified JSON, ensuring the UI displays meaningful tool invocation labels instead of generic fallbacks.

Key changes:

  • Enhance safeJsonParse utility to detect and parse double-stringified JSON strings.
  • Update parseToolReturnMessage to use the improved parsing for MCP tool return messages (mcp__atlassian__invoke_tool, mcp__atlassian__get_tool_schema, mcp__scout__invoke_tool).
  • Add comprehensive tests covering scenarios with double-stringified MCP tool arguments to prevent regressions.

Impact:

  • Prevents silent degradation where users see generic fallback text instead of specific MCP tool invocation details.
  • Improves user experience by showing accurate tool invocation messages in the chat UI.
  • Maintains existing error handling without crashing or blocking user interaction.

This is a defensive, low-risk fix that mitigates a medium-severity issue affecting MCP tool integrations. Further backend investigation and UX improvements are recommended as next steps.


Rovo Dev code review: Rovo Dev has reviewed this pull request
Any suggestions or improvements have been posted as pull request comments.

Add defensive parsing in safeJsonParse to detect and parse double-stringified JSON payloads for MCP tool return messages. This prevents SyntaxError caused by backend accidentally double-stringifying toolCallMessage.args in MCP tool returns (e.g., mcp__atlassian__invoke_tool). Update parseToolReturnMessage tests to cover this scenario, ensuring the UI shows meaningful tool invocation labels instead of generic fallbacks. This fix improves robustness and user experience by correctly displaying MCP tool details in the chat UI.
@atlassian

atlassian Bot commented Jul 3, 2026

Copy link
Copy Markdown
Contributor

The issue is ready for review, and the acceptance criteria have been met:

  • ✅ Implement defensive JSON parsing to handle double-stringified MCP tool args in parseToolReturnMessage, so the UI displays meaningful tool invocation labels instead of generic fallbacks.
  • ✅ Add test coverage for double-stringified JSON scenarios to prevent regressions.
  • ✅ Maintain existing error handling without crashing or blocking user interaction.

Check Jira issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant