Skip to content

fix: sanitize null values in tool arguments to prevent empty field errors#1256

Open
Jim1874 wants to merge 1 commit intoagentscope-ai:mainfrom
Jim1874:claude/agentscope-ai_agentscope-java_issue_1163
Open

fix: sanitize null values in tool arguments to prevent empty field errors#1256
Jim1874 wants to merge 1 commit intoagentscope-ai:mainfrom
Jim1874:claude/agentscope-ai_agentscope-java_issue_1163

Conversation

@Jim1874
Copy link
Copy Markdown

@Jim1874 Jim1874 commented Apr 19, 2026

Summary

Fix tool parameter conversion bug where passing an object with empty fields causes errors. Null values are now sanitized to empty strings or empty arrays before being passed to tool arguments.

Changes

  • Added null value sanitization in DashScopeToolsHelper.java and OpenAIMessageConverter.java
  • Added JacksonJsonCodec.java with utility for safe null-to-empty conversion
  • Ensures all object fields are properly initialized before tool call execution

…rors

When passing objects as tool parameters, empty/null fields cause errors
in downstream APIs. This fix:

- Adds toMapWithSanitizedNulls() in JacksonJsonCodec to recursively
  replace null values and empty nested maps with empty strings
- Updates DashScopeToolsHelper.convertToolCalls() to use sanitization
- Updates OpenAIMessageConverter to use same sanitization

Fixes agentscope-ai#1163
@Jim1874 Jim1874 requested a review from a team April 19, 2026 07:24
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.


huangzhimou seems not to be a GitHub user. You need a GitHub account to be able to sign the CLA. If you have already a GitHub account, please add the email address used for this commit to your account.
You have signed the CLA already but the status is still pending? Let us recheck it.

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.

2 participants