This is an automated email from the ASF dual-hosted git repository.

liuhongyu pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git


The following commit(s) were added to refs/heads/master by this push:
     new 1464229396 fix get the argument position mapping error and test method 
(#6236)
1464229396 is described below

commit 1464229396fbec10def6827e4f082f9427931c36
Author: MaMengzhen <[email protected]>
AuthorDate: Thu Nov 27 15:02:40 2025 +0800

    fix get the argument position mapping error and test method (#6236)
    
    * fix Get the argument position mapping error and test method
    
    * fix testCallWithMissingExchange
    
    * fix 'testPostRequestWithJsonBody' json data format
    
    ---------
    
    Co-authored-by: mamz10 <[email protected]>
    Co-authored-by: aias00 <[email protected]>
---
 .../apache/shenyu/plugin/mcp/server/request/RequestConfigHelper.java   | 2 +-
 .../shenyu/plugin/mcp/server/callback/ShenyuToolCallbackTest.java      | 3 +++
 .../shenyu/plugin/mcp/server/request/RequestConfigHelperTest.java      | 2 +-
 3 files changed, 5 insertions(+), 2 deletions(-)

diff --git 
a/shenyu-plugin/shenyu-plugin-mcp-server/src/main/java/org/apache/shenyu/plugin/mcp/server/request/RequestConfigHelper.java
 
b/shenyu-plugin/shenyu-plugin-mcp-server/src/main/java/org/apache/shenyu/plugin/mcp/server/request/RequestConfigHelper.java
index 1c70a3bccb..556b0cc490 100644
--- 
a/shenyu-plugin/shenyu-plugin-mcp-server/src/main/java/org/apache/shenyu/plugin/mcp/server/request/RequestConfigHelper.java
+++ 
b/shenyu-plugin/shenyu-plugin-mcp-server/src/main/java/org/apache/shenyu/plugin/mcp/server/request/RequestConfigHelper.java
@@ -51,7 +51,7 @@ public class RequestConfigHelper {
      * @return the argument position json object
      */
     public JsonObject getArgsPosition() {
-        return getRequestTemplate().get("argsPosition").getAsJsonObject();
+        return configJson.has("argsPosition") ? 
configJson.getAsJsonObject("argsPosition") : new JsonObject();
     }
 
     /**
diff --git 
a/shenyu-plugin/shenyu-plugin-mcp-server/src/test/java/org/apache/shenyu/plugin/mcp/server/callback/ShenyuToolCallbackTest.java
 
b/shenyu-plugin/shenyu-plugin-mcp-server/src/test/java/org/apache/shenyu/plugin/mcp/server/callback/ShenyuToolCallbackTest.java
index 8b5aa08976..39035071b9 100644
--- 
a/shenyu-plugin/shenyu-plugin-mcp-server/src/test/java/org/apache/shenyu/plugin/mcp/server/callback/ShenyuToolCallbackTest.java
+++ 
b/shenyu-plugin/shenyu-plugin-mcp-server/src/test/java/org/apache/shenyu/plugin/mcp/server/callback/ShenyuToolCallbackTest.java
@@ -157,6 +157,9 @@ class ShenyuToolCallbackTest {
     @Test
     void testCallWithMissingExchange() throws Exception {
         when(toolDefinition.name()).thenReturn("testTool");
+        when(toolDefinition.requestConfig()).thenReturn(
+                
"{\"requestTemplate\":{\"url\":\"/test\",\"method\":\"GET\"},\"argsPosition\":{}}"
+        );
         shenyuToolCallback = new ShenyuToolCallback(toolDefinition);
         
         final ToolContext toolContext = new ToolContext(new HashMap<>());
diff --git 
a/shenyu-plugin/shenyu-plugin-mcp-server/src/test/java/org/apache/shenyu/plugin/mcp/server/request/RequestConfigHelperTest.java
 
b/shenyu-plugin/shenyu-plugin-mcp-server/src/test/java/org/apache/shenyu/plugin/mcp/server/request/RequestConfigHelperTest.java
index 1d312eb4c2..520efbdbb2 100644
--- 
a/shenyu-plugin/shenyu-plugin-mcp-server/src/test/java/org/apache/shenyu/plugin/mcp/server/request/RequestConfigHelperTest.java
+++ 
b/shenyu-plugin/shenyu-plugin-mcp-server/src/test/java/org/apache/shenyu/plugin/mcp/server/request/RequestConfigHelperTest.java
@@ -47,7 +47,7 @@ class RequestConfigHelperTest {
     void testPostRequestWithJsonBody() {
         String configStr = "{\"requestTemplate\":{\"url\":\"/api/users\","
                 + "\"method\":\"POST\",\"headers\":[{\"key\":\"Content-Type\","
-                + 
"\"value\":\"application/json\"}],\"argsToJsonBody\":true,\"argsPosition\":{\"name\":\"body\",\"email\":\"body\"}}}";
+                + 
"\"value\":\"application/json\"}],\"argsToJsonBody\":true},\"argsPosition\":{\"name\":\"body\",\"email\":\"body\"}}";
         RequestConfigHelper helper = new RequestConfigHelper(configStr);
         
         assertEquals("/api/users", helper.getUrlTemplate());

Reply via email to