lymerin opened a new pull request, #7488:
URL: https://github.com/apache/shenyu/pull/7488

   Fixes #7474
   
   ### Problem
   
   - When plugin-level AI Prompt configuration exists and a request matches a 
rule with a handle, `AiPromptPlugin.doExecute()` writes the rule's `preRole`, 
`prepend`, `postRole`, and `append` directly into the shared `AiPromptConfig` 
singleton.
   - All four setters are unconditional, so missing rule fields also overwrite 
the corresponding plugin-level fields with `null`. The request-body callback 
captures that same shared object and reads it later when subscribed. 
   
   ### Impact
   
   - Rule prompt text and roles remain in the global configuration and affect 
subsequent requests without a rule handle. Partial rule handles also clear 
plugin-level fields.
   - Overlapping requests share the same mutable configuration, allowing one 
request's rule overrides to affect another request's body decoration.
   - The affected scope is AI Prompt request handling within the gateway 
process. The modified global configuration persists until another rule 
overwrites it or plugin configuration synchronization replaces it.
   
   ### Changes
   
   - Apply rule settings to a new AiPromptConfig, preventing changes to the 
global config. This adds one production line.
   - Keep existing behavior: rule settings replace all four fields, including 
null; requests without a handle use the plugin config or the existing empty 
fallback.
   - Follow the replacement behavior used in #6053 and #6095, rather than the 
issue's suggested copy-based approach.
   
   Add one regression test through doExecute():
   - Construct A and B before subscribing, then verify their independent 
outputs. B does not inherit the plugin-level prepend.
   - Verify that subsequent request C, without a handle, uses the original 
plugin config.
   - Verify that all four global fields remain unchanged, then restore the 
previous config and remove the test's cache entries.
   ### Validation
   
   - After the fix, all 16 module tests passed, with zero failures, errors, or 
skipped tests.
   - Checkstyle passed with zero violations.
   
   ### Checklist
   
   Make sure that:
   
   - [x] You have read the [[contribution 
guidelines](https://shenyu.apache.org/community/contributor-guide)](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]

Reply via email to