Skip to content

fix(core): guard null input in ToolValidator.validateInput to prevent NPE#2337

Open
1143506050 wants to merge 1 commit into
agentscope-ai:mainfrom
1143506050:fix/tool-validator-null-input
Open

fix(core): guard null input in ToolValidator.validateInput to prevent NPE#2337
1143506050 wants to merge 1 commit into
agentscope-ai:mainfrom
1143506050:fix/tool-validator-null-input

Conversation

@1143506050

Copy link
Copy Markdown

When a ToolUseBlock has parsed arguments in its input map but no raw
content string, ToolExecutor.executeCore passes null to
ToolValidator.validateInput(), which forwards it to networknt-schema's
validate(null, …). networknt-schema then throws:

  NullPointerException: argument "content" is null

This causes tool calls to fail with a misleading error:
Parameter validation failed: Schema validation error: argument "content" is null

Treat null/blank input as "{}" before validation so that optional-field
schemas pass cleanly and required-field schemas still surface the expected
validation errors.

When a ToolUseBlock has parsed arguments in its `input` map but no raw
`content` string, `ToolExecutor.executeCore` passes `null` to
`ToolValidator.validateInput()`, which forwards it to networknt-schema's
`validate(null, …)`.  networknt-schema then throws

    NullPointerException: argument "content" is null

Treat null/blank input as `"{}"` before validation so that optional-field
schemas pass cleanly and required-field schemas still surface the expected
validation errors.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@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.


wyp 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.

@oss-maintainer

Copy link
Copy Markdown
Collaborator

CLA Not Signed

The Contributor License Agreement (CLA) check is currently pending on this PR (license/cla: Contributor License Agreement is not signed yet.). This PR cannot be merged until the CLA is signed.

@1143506050 please sign the CLA via the CLA assistant badge in the comment above, or visit https://cla-assistant.io/agentscope-ai/agentscope-java. Once signed, the license/cla status will turn green.


Automated check by github-manager-bot

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.

3 participants