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

   ### Behavior and reproduction
   
   A response-transformation rule builds a prompt containing the original 
request body, but reads that body after the downstream HTTP chain has already 
consumed it. With a normal one-shot POST body, the model receives an empty/null 
request body, or the second subscription fails, even though the backend 
received the real payload.
   
   Reproduced at `fda742c48e7f553c9964cf74b36732326d0fde00` with the real 
`AiResponseTransformerTemplate` and Spring codecs. A one-shot request publisher 
emits `{"customer":"alice"}` once. Consume it as the downstream HTTP client 
does, then assemble the response prompt. Observed: backend body is the full 
JSON, request-body subscription count is **2**, and the prompt contains no 
`alice` (its request body is null). A replayable MockServerHttpRequest body 
masks this lifecycle problem.
   
   ### Location and cause
   
   - [Capture the original request, then invoke the downstream 
chain](https://github.com/apache/shenyu/blob/fda742c48e7f553c9964cf74b36732326d0fde00/shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-response-transformer/src/main/java/org/apache/shenyu/plugin/ai/transformer/response/AiResponseTransformerPlugin.java#L132)
   - [Assemble the prompt during response 
writing](https://github.com/apache/shenyu/blob/fda742c48e7f553c9964cf74b36732326d0fde00/shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-response-transformer/src/main/java/org/apache/shenyu/plugin/ai/transformer/response/AiResponseTransformerPlugin.java#L337)
   - [Subscribe to 
originalRequest.getBody()](https://github.com/apache/shenyu/blob/fda742c48e7f553c9964cf74b36732326d0fde00/shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-response-transformer/src/main/java/org/apache/shenyu/plugin/ai/transformer/response/template/AiResponseTransformerTemplate.java#L157)
   
   There is no replayable request-body decorator or snapshot installed by this 
plugin before downstream consumption. The response transformer retaining a 
ServerHttpRequest object does not retain its consumed body.
   
   ### Expected behavior / suggested repair
   
   Capture a bounded request-body snapshot before forwarding and preserve a 
replayable stream for the downstream consumer. Build the prompt from that 
snapshot; do not subscribe to the original transport body twice. Test both the 
backend body and model prompt through one-shot POST/PUT bodies, with empty-body 
and cancellation controls.
   
   ### Scope / related issues
   
   Functional correctness, medium severity. Distinct from #6773 (unset response 
status), #6795 (stream response buffering), and #6757 (writeAndFlushWith 
interception). No code fix is included in this audit issue.
   


-- 
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