Aias00 opened a new issue, #7909:
URL: https://github.com/apache/shenyu/issues/7909

   ### Behavior and reproduction
   
   A configured GET HTTP tool with a query argument is routed to the wrong URL 
when it uses the normal HTTP route path without a ContextPath rule rewriting 
realUrl.
   
   At `fda742c48e7f553c9964cf74b36732326d0fde00`, configure tool `lookup` with 
route `/orders/status`, GET, and `argsPosition={"id":"query"}`; invoke it with 
`{"id":"A"}`. Execute the real AgentHttpToolExecutor with a forked chain that 
calls the production RequestUrlUtils.buildRequestUri, as HTTP forwarding does.
   
   Observed upstream target:
   
   ```text
   http://127.0.0.1:18080/orders/status?id=A?id=A
   ```
   
   Expected: `http://127.0.0.1:18080/orders/status?id=A`.
   
   The probe completed the actual private tool response successfully; the 
failure is the URL handed to the ordinary route, not an invalid tool schema or 
missing HTTP dispatch setup.
   
   ### Location and cause
   
   - [Set child request URI from path including 
query](https://github.com/apache/shenyu/blob/fda742c48e7f553c9964cf74b36732326d0fde00/shenyu-plugin/shenyu-plugin-agent-gateway/src/main/java/org/apache/shenyu/plugin/agent/gateway/tool/AgentHttpToolExecutor.java#L123)
   - [Also set context.realUrl to that query-bearing 
path](https://github.com/apache/shenyu/blob/fda742c48e7f553c9964cf74b36732326d0fde00/shenyu-plugin/shenyu-plugin-agent-gateway/src/main/java/org/apache/shenyu/plugin/agent/gateway/tool/AgentHttpToolExecutor.java#L137)
   - [Normal URI builder appends the request query to 
context.realUrl](https://github.com/apache/shenyu/blob/fda742c48e7f553c9964cf74b36732326d0fde00/shenyu-plugin/shenyu-plugin-api/src/main/java/org/apache/shenyu/plugin/api/utils/RequestUrlUtils.java#L61)
   
   The query is present in both realUrl and the child request URI, so 
forwarding appends it twice. Existing executor tests check the child's request 
URI but not the final upstream URI.
   
   ### Expected behavior / suggested repair
   
   Keep only the route path in the ShenyuContext realUrl and leave encoded 
query arguments in the child URI. Verify the normal HTTP forwarding builder 
with GET and POST query arguments, encoded values, no-query controls, and 
routes with/without a ContextPath rule. This is a functional routing bug in the 
new configured HTTP tools, distinct from tool authorization and external MCP 
directory behavior.
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to