shenyu icon indicating copy to clipboard operation
shenyu copied to clipboard

[BUG] JsonSchemaUtil never emits required array — all MCP tool parameters advertised as optional

Open Aias00 opened this issue 4 months ago • 5 comments

Description

executeToolCall subscribes fire-and-forget (chain.execute(decoratedExchange).subscribe(...) at line 266) then blocks on responseFuture.get(DEFAULT_TIMEOUT_SECONDS, …). On TimeoutException it throws, but the Disposable returned by subscribe() is never captured/cancelled, and doFinally does not cancel the chain. The downstream request keeps running after the tool call has already returned an error to the MCP client.

Location

  • shenyu-plugin/shenyu-plugin-mcp-server/src/main/java/org/apache/shenyu/plugin/mcp/server/callback/ShenyuToolCallback.java:266-283

Impact

Timed-out tool calls leak downstream work/connections and may produce side effects (e.g. upstream API calls) after the client has received an error.

Suggested fix

Capture the Disposable, and on TimeoutException call disposable.dispose() before throwing.

Related existing

None — distinct from MCP-01..05 (#6640-#6644, response decorator) and MCP-11 (notifications).

Aias00 avatar Aug 04 '26 03:08 Aias00

👋 Hello @Aias00

A new issue has been opened by @Aias00:

  • Title: [BUG] JsonSchemaUtil never emits required array — all MCP tool parameters advertised as optional
  • Link: https://github.com/apache/shenyu/issues/6888

Please review when you have time. Thank you! 🙏

github-actions[bot] avatar Aug 04 '26 03:08 github-actions[bot]

I'd like to handle it😄pls distribute it to me

SouthwestAsiaFloat avatar Aug 16 '26 12:08 SouthwestAsiaFloat

I'd like to handle it😄pls distribute it to me

go for it

Aias00 avatar Aug 16 '26 13:08 Aias00

Follow-up to the title/body mismatch noted on #6889: this issue is closed by merged PR #6937, which fixes the MCP timeout behavior described in this issue body. However, the current title says JsonSchemaUtil never emits required array, a different bug. Together with #6889 (MCP timeout title, MQTT session body, active MQTT PR #6894), the two issues appear to have crossed titles. Could a maintainer confirm whether the JsonSchema required-array bug was separately fixed or needs a new/reopened issue? The #6937 closure only verifies the MCP timeout behavior in the current body.

sunnysabor avatar Oct 01 '26 16:10 sunnysabor

Correction to my previous comment after tracing the neighboring reports and merged fixes: the JsonSchema required array bug is already fixed by PR #6994, which closes #6887; #6887’s body describes that JsonSchema bug despite its unrelated title. The MCP timeout described in #6888’s body is fixed by #6937, and the MQTT session bug described in #6889’s body is what #6894 addresses. So I found no evidence that the JsonSchema defect needs reopening; the remaining cleanup is to align the three issue titles with their bodies. My earlier question about creating/reopening a JsonSchema issue was mistaken.

sunnysabor avatar Oct 01 '26 16:10 sunnysabor