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

   ### Is there an existing issue for this?
   
   - [x] I have searched the existing issues.
   
   ### Current Behavior
   
   AiResponseTransformerPlugin loads the global AiResponseTransformerConfig, 
but if any cached rule handle exists it replaces that config with a new empty 
object and copies only the rule's non-null fields. A rule that supplies only 
content/model loses the globally configured provider, baseUrl and apiKey. The 
subsequent null check logs missing configuration and delegates to the chain 
without installing response transformation. Even an empty parsed handle can 
disable otherwise valid global settings.
   
   ### Expected Behavior
   
   Resolve effective configuration by copying global defaults and overlaying 
supported rule overrides, consistent with the code's stated rule-precedence 
behavior. If partial overrides are intentionally unsupported, reject them 
clearly at configuration validation rather than accepting them and silently 
bypassing transformation. Client creation/cache identity must match the 
effective settings.
   
   ### Steps To Reproduce
   
   1. Configure valid plugin-level provider/baseUrl/apiKey/model and verify a 
response transforms without a rule override.
   2. Configure a matching rule handle containing only content (a different 
prompt), leaving connection fields omitted.
   3. doExecute creates an empty config, copies content and finds the 
connection fields null; it continues downstream without applying transformation.
   4. Repeat with an empty handle and a model-only override.
   
   This is a code-derived regression scenario; no external model service or 
Java test was run here.
   
   ### Environment
   
   - ShenYu master / 2.7.2-SNAPSHOT, commit 
`34f2ed036747936a5e28aea2c94cd9b3cddcce47`.
   - Source-inspection report. The reporting environment has no available JDK; 
no Maven/JUnit, live backend or Redis reproduction is claimed.
   - Existing runtime behavior; unrelated to proposed plugin orchestration.
   
   ### Debug logs
   
   No runtime logs captured. Code evidence follows.
   
   ### Code evidence
   
   - [Global config discarded before partial rule 
overlay](https://github.com/apache/shenyu/blob/34f2ed036747936a5e28aea2c94cd9b3cddcce47/shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-response-transformer/src/main/java/org/apache/shenyu/plugin/ai/transformer/response/AiResponseTransformerPlugin.java#L97-L126)
   - [Connection fields have no implicit 
defaults](https://github.com/apache/shenyu/blob/34f2ed036747936a5e28aea2c94cd9b3cddcce47/shenyu-common/src/main/java/org/apache/shenyu/common/dto/convert/plugin/AiResponseTransformerConfig.java)
   - [Global configuration/default client and rule handle 
caching](https://github.com/apache/shenyu/blob/34f2ed036747936a5e28aea2c94cd9b3cddcce47/shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-response-transformer/src/main/java/org/apache/shenyu/plugin/ai/transformer/response/handler/AiResponseTransformerPluginHandler.java)
   - [Rule/default client 
cache](https://github.com/apache/shenyu/blob/34f2ed036747936a5e28aea2c94cd9b3cddcce47/shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-response-transformer/src/main/java/org/apache/shenyu/plugin/ai/transformer/response/cache/ChatClientCache.java)
   
   ### Suggested fix direction
   
   Create a request-local copy of global settings, overlay rule fields without 
mutating the shared singleton, then resolve/cache the client from that 
effective configuration. Make blank/null override semantics explicit and ensure 
later global changes cannot leave inherited rule settings paired with a stale 
client.
   
   ### Acceptance criteria
   
   - Content-only/model-only/empty handles do not discard valid inherited 
connection settings.
   - Explicit rule connection overrides win without affecting other rules or 
the global singleton.
   - Invalid effective config is reported clearly; no misleading successful 
activation followed by silent bypass.
   - Cover global-setting updates and rule client cache invalidation against 
the final effective config.
   
   ### Related work and scope
   
   Independent of #7906 (request-body resubscription) and #6648 
(ChatClientCache thread safety). Suggested priority: P2.
   


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