Skip to content

fix: skip nested required array when converting mcp tool args - #352

Merged
learnerjohn merged 1 commit into
higress-group:mainfrom
wzlee:fix/nested-object-required-array
Oct 23, 2026
Merged

learnerjohn merged 1 commit into
higress-group:mainfrom
wzlee:fix/nested-object-required-array

Conversation

@wzlee

@wzlee wzlee commented Oct 22, 2026

Copy link
Copy Markdown
Contributor

📝 Description

Importing an MCP server whose tool inputSchema contains a nested object property failed with:

Cannot deserialize value of type `boolean` from Array value (token `JsonToken.START_ARRAY`)
 through reference chain: ...OpenAPIToolsConfig$Arg["required"]

A nested object schema carries its own required array (the list of required child properties), but OpenAPIToolsConfig.Arg.required is a boolean meaning "this argument is required by the parent". When OpenAPIToolsConfigConverter.convertArgs passed the raw property map to JsonUtil.convert(..., Arg.class), Jackson tried to bind the array onto the boolean and threw.

  • Copy each property map before conversion and drop its required key; the boolean is still set from the parent-level required list right after conversion, so the semantics for top-level args are unchanged
  • The nested properties map is kept intact, so child schemas (including their own required arrays) remain available on Arg.properties
  • Add a unit test covering a tool whose argument is an object with a required array

✅ Type of Change

  • Bug fix (non-breaking change)
  • New feature (non-breaking change)
  • Breaking change
  • Documentation update
  • Code refactoring
  • Performance improvement

🧪 Testing

  • Unit tests added/updated
    • OpenAPIToolsConfigConverterTest.shouldConvertNestedObjectRequiredArray: nested object argument with a required array converts without error, keeps required=true from the parent list and preserves nested properties
  • Existing OpenAPIToolsConfigConverterTest cases still pass
  • Manual testing: an MCP server with an object-typed tool argument can now be imported and saved

📋 Checklist

  • Code has been formatted (mvn spotless:apply for backend)
  • Code is self-reviewed
  • No breaking changes
  • All CI checks pass

🤖 Generated with Claude Code

…token `JsonToken.START_ARRAY`)

         through reference chain: ...OpenAPIToolsConfig$Arg["required"]
@learnerjohn
learnerjohn self-requested a review October 23, 2026 06:41
@learnerjohn
learnerjohn merged commit 3a63fc5 into higress-group:main Oct 23, 2026
9 of 10 checks passed
@wzlee
wzlee deleted the fix/nested-object-required-array branch October 30, 2026 11:37
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