apache / apache/shenyu

[BUG] removeRule destroys the wrong cache key, leaking stale ChatClients

Open Beginner friendly
#6,755 1 comment 0 reactions 0 assignees View on GitHub
feature: plugin priority: medium type: bug
Dominant language
Java
Stars
8.8k
Forks
3.1k
Avg merge
7d 1h
Merged PRs (30d)
85

Description

- severity: Medium
- files: `shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-request-transformer/src/main/java/org/apache/shenyu/plugin/ai/transformer/request/handler/AiRequestTransformerPluginHandler.java:80`; `.../ai-response-transformer/.../handler/AiResponseTransformerPluginHandler.java:97`
- description: The plugin creates/looks up clients under key `rule.getId()` but `removeRule` calls `destroyClient(ruleData.getId() + aiRequestTransformerHandle.getProvider())` — a composite key never used for insertion. Removal is a no-op: the cached `ChatClient`/`ChatModel` (and its underlying HTTP client) is never evicted.
- impact: Stale model clients with rotated API keys remain in memory; resource leak.
- suggested_fix: `removeRule` should call `destroyClient(ruleData.getId())`.
- confidence: High
- related_existing: none

---
_Identified during the 2026-08-02 deep re-scan; full list in [`docs/scan2-2026-08-02/06-medium-tiers.md`](docs/scan2-2026-08-02/06-medium-tiers.md)._

Contributor guide

No contributing guide indexed for this repository

Research direction

Start with removeRule in AiRequestTransformerPluginHandler.java:80 and AiResponseTransformerPluginHandler.java:97, then trace the client cache insertion and removal keys. Verify both handlers use the rule ID consistently and inspect the relevant module tests, if present. Done means removing a rule evicts its cached ChatClient/ChatModel and underlying HTTP client rather than leaving stale entries.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
backend
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Quiet
Clarity
Clearly specified
Newbie friendliness
72/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.