Aias00 opened a new issue, #7460: URL: https://github.com/apache/shenyu/issues/7460
## Is there an existing issue for this? - [x] I searched open and closed issues. ## Current Behavior An accepted AI-generated path-only rewrite changes ServerHttpRequest.URI but leaves ShenYu routing context unchanged. Standard configured-upstream HTTP forwarding then builds the outbound URI using the old realUrl. Starting from `/original?old=1`, a generated `POST /rewritten HTTP/1.1` passes validation. The mutated request URI is `/rewritten`, but ShenyuContext.path/realUrl remain `/original`. RequestUrlUtils.buildRequestUri() therefore builds `http://upstream.example/original`. The generated body/headers can be forwarded to the old backend path. URI-based matching and context-based forwarding disagree. ## Expected Behavior After accepting a request-target rewrite, synchronize the routing state consumed by the standard outbound HTTP path. The backend path should agree with the accepted generated target, subject to explicitly configured context-path or Rewrite overrides. ## Reproduction 1. Initialize an ordinary HTTP exchange for `/original?old=1` with ShenyuContext.path/realUrl set to `/original`, as GlobalPlugin does. 2. Configure AI request transformation with a mocked response containing `POST /rewritten HTTP/1.1` and a generated JSON body/header. 3. Run actual AiRequestTransformerPlugin.doExecute(). 4. Capture the mutated request/context and invoke the actual RequestUrlUtils URI builder with a configured upstream domain, with no explicit Rewrite override. Observed current-source output: ```text pathOnly.uri=http://localhost/rewritten pathOnly.body={"ai":"path"} pathOnly.contextPath=/original pathOnly.contextRealUrl=/original pathOnly.outboundUri=http://upstream.example/original ``` ## Location And Impact - [AiRequestTransformerPlugin.java:260](https://github.com/apache/shenyu/blob/67596c1d228b62da75cd0a0ecb47d0ac5d995384/shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-request-transformer/src/main/java/org/apache/shenyu/plugin/ai/transformer/request/AiRequestTransformerPlugin.java#L260): resolves and mutates the request URI without synchronizing context or rewrite attributes. - [RequestUrlUtils.java:44](https://github.com/apache/shenyu/blob/67596c1d228b62da75cd0a0ecb47d0ac5d995384/shenyu-plugin/shenyu-plugin-api/src/main/java/org/apache/shenyu/plugin/api/utils/RequestUrlUtils.java#L44): outbound construction prefers REWRITE_URI, then ShenyuContext.realUrl. - [URIPlugin.java:42](https://github.com/apache/shenyu/blob/67596c1d228b62da75cd0a0ecb47d0ac5d995384/shenyu-plugin/shenyu-plugin-uri/src/main/java/org/apache/shenyu/plugin/uri/URIPlugin.java#L42): stores that URI for the HTTP client. Severity: Medium. Confidence: high. Accepted path rewrites can be invisible to the HTTP backend while generated request data is applied; routing and forwarding can disagree. Scope is the standard HTTP forwarding path with initialized context and no explicit later override that corrects the path. ## Suggested Fix And Regression Coverage Use the existing request-rewrite/context contract so accepted target changes reach outbound URI construction. Synchronize path/realUrl or the appropriate rewrite attributes, preserving context-path semantics and explicit configured overrides. Add a transformer-through-outbound-URI regression, not only a request-URI assertion. Cover path-only targets, query-bearing targets once supported, context-path prefixes, and explicit Rewrite overrides. ## Validation And Related Issues Reviewed master `67596c1d228b62da75cd0a0ecb47d0ac5d995384` (`2.7.2-SNAPSHOT`). Isolated verification traced GlobalPlugin -> AI transformer -> optional ContextPath -> URIPlugin/RequestUrlUtils -> HTTP client. The actual transformer and actual URI builder reproduced the stale outbound path; leader recompiled current source and repeated the asserted harness. This differs from query-target rejection: `/rewritten` is accepted and request URI changes, but forwarding remains stale. Fixing query validation alone will not fix this case. #6508 is context-path prefix handling; #6207 concerns MCP path truncation; no matching AI transformer outbound-context issue was found in baseline/live searches. No external AI/backend calls or full deployed E2E were run. -- 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]
