Skip to content

Fix getErrorMessage() to avoid leaking "[object Object]" for non-string message fields (MCE-006) - #55042

Draft
pelikhan with Copilot wants to merge 3 commits into
mainfrom
copilot/mce-006-fix-error-message-serialization
Draft

Fix getErrorMessage() to avoid leaking "[object Object]" for non-string message fields (MCE-006)#55042
pelikhan with Copilot wants to merge 3 commits into
mainfrom
copilot/mce-006-fix-error-message-serialization

Conversation

Copilot AI commented Aug 23, 2026

Copy link
Copy Markdown
Contributor

getErrorMessage() in error_helpers.cjs fell back to String(error) (stringifying the entire error object) whenever a thrown plain object had a .message property that existed but wasn't a string, producing "[object Object]" in MCP error responses instead of a useful message. The conformance checker also couldn't tell this apart from a total absence of error serialization, since it only grepped for a literal String(e.message) pattern.

  • actions/setup/js/error_helpers.cjs
    • When error.message exists but isn't a string, coerce just that value (String(error.message)) instead of stringifying the whole error object.
} else if (error && typeof error === "object" && "message" in error) {
  message = typeof error.message === "string" ? error.message : String(error.message);
} else {
  message = String(error);
}
  • actions/setup/js/error_helpers.test.cjs

    • Corrected the existing numeric-message test (was asserting the buggy "[object Object]" output).
    • Added a case with a non-primitive message (array) asserting the result is never "[object Object]".
  • scripts/check-safe-outputs-conformance.sh (MCE-006)

    • Now also passes when mcp_server_core.cjs delegates to the shared getErrorMessage helper and error_helpers.cjs itself guards against non-string .message values, rather than only matching the literal String(e.message) pattern in the core file.

Copilot AI and others added 2 commits August 23, 2026 07:48
…ields (MCE-006)

Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Co-authored-by: pelikhan <4175913+pelikhan@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix error message serialization to avoid leaking [object Object] Fix getErrorMessage() to avoid leaking "[object Object]" for non-string message fields (MCE-006) Aug 23, 2026
Copilot AI requested a review from pelikhan August 23, 2026 07:49
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.

[Safe Outputs Conformance] MCE-006: getErrorMessage can leak [object Object] for non-string thrown message fields

2 participants