Skip to content

Conversation

@tt-a1i
Copy link
Contributor

@tt-a1i tt-a1i commented Jan 1, 2026

Summary

Fixes #1338

Previously, when a tool execution failed with an error object (not an Error instance), getErrorMessage() would return [object Object], hiding useful error information from users.

Changes

This PR improves getErrorMessage() to properly handle non-Error objects:

  1. Extract the message property from error-like objects (e.g., { message: 'test' }'test')
  2. JSON.stringify plain objects to show their full content (e.g., { code: 500 }'{"code":500}')
  3. Fall back to String() only when JSON.stringify fails (circular references, etc.)

Test plan

  • Updated existing tests to reflect new behavior
  • Added tests for error-like objects with message property
  • Added tests for plain objects without message property
  • Added tests for edge cases (empty objects, non-string message)
  • All existing tests pass

AI Assistance Disclosure

I used Codex to review the changes, sanity-check the implementation against existing patterns, and help spot potential edge cases.

tt-a1i added 2 commits January 1, 2026 09:56
Previously, when a tool execution failed with an error object (not an
Error instance), getErrorMessage() would return '[object Object]',
hiding useful error information from users.

This change improves getErrorMessage() to:
1. Extract the 'message' property from error-like objects
2. JSON.stringify plain objects to show their full content
3. Fall back to String() only when JSON.stringify fails

Fixes QwenLM#1338
Add fallback to String() when JSON.stringify returns undefined,
which can happen with objects that have toJSON() returning undefined.
@yiliang114
Copy link
Collaborator

@tt-a1i Thank you for your contribution, there seems to be no problem! I will actually verify the case I have encountered. If there is no problem, we will merge as soon as possible.

@yiliang114 yiliang114 self-assigned this Jan 1, 2026
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.

The error information of some tool execution failures is not complete?or by desigin?

2 participants