lymerin opened a new pull request, #7535:
URL: https://github.com/apache/shenyu/pull/7535
Fixes #7460
### Problem
When the AI request transformer accepts a path rewrite, it updates
`ServerHttpRequest.URI` but leaves `ShenyuContext.path` and
`ShenyuContext.realUrl` unchanged.
For a request such as `/original` rewritten by AI to `/rewritten`, the
request URI becomes `/rewritten`, while the routing context still points to
`/original`. `RequestUrlUtils.buildRequestUri()` then builds the
configured-upstream request from the stale `realUrl`.
### Impact
The transformed request body and headers can be forwarded to the old backend
path even though the AI-generated path was accepted.
This affects the standard HTTP forwarding path when the AI request
transformer changes the request path and no later explicit routing override
replaces it.
### Changes
- Synchronize `ShenyuContext.path` with the accepted rewritten request path.
- Update `ShenyuContext.realUrl` when it still represents the original path,
while preserving an already transformed forwarding path.
- Preserve the existing priority of an explicit `REWRITE_URI`.
- Add regression coverage through the actual transformer and
`RequestUrlUtils`:
- verify `/original` rewritten to `/rewritten` is forwarded to
`/rewritten`;
- verify an explicit `REWRITE_URI` still takes precedence.
### Validation
- The request-routing regression tests passed.
- The full local build passed with `./mvnw clean install
-Dmaven.javadoc.skip=true`.
### Checklist
Make sure that:
- [x] You have read the [contribution
guidelines](https://shenyu.apache.org/community/contributor-guide).
- [x] You submit test cases (unit or integration tests) that back your
changes.
- [x] Your local test passed `./mvnw clean install
-Dmaven.javadoc.skip=true`.
--
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]