apache / apache/shenyu

[BUG] AI proxy plugin-level config is not applied at runtime

Open
#6,470 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
8.8k
Forks
3.1k
Avg merge
7d 1h
Merged PRs (30d)
85

Description

### Current Behavior

The enhanced AI proxy runtime still tries to resolve a global `AiCommonConfig` from `Singleton.INST`, but the plugin data handler never stores plugin-level configuration there.

`AiProxyConfigService.resolvePrimaryConfig()` reads and merges global config:

```java
final AiCommonConfig globalConfig = Singleton.INST.get(AiCommonConfig.class);
...
if (Objects.nonNull(globalConfig)) {
primaryConfig.mergeWith(globalConfig);
}
```

However, `AiProxyPluginHandler.handlerPlugin()` intentionally performs no plugin config handling:

```java
// No global plugin configuration handling is performed.
```

As a result, plugin-level/global AI proxy defaults configured in admin are not applied at runtime. If a selector relies on global defaults for required fields such as provider/model/baseUrl/apiKey, `AiProxyPlugin.createChatModel()` later fails because the resolved config is incomplete.

### Expected Behavior

Either plugin-level AI proxy configuration should be loaded into the runtime config path used by `resolvePrimaryConfig()`, or the runtime should stop advertising/depending on a global config merge path.

### Impact

Deployments that configure shared AI proxy defaults at plugin/global level can fail requests unless every selector repeats a fully populated AI provider configuration.

### Code Location

- `shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-proxy/src/main/java/org/apache/shenyu/plugin/ai/proxy/enhanced/service/AiProxyConfigService.java`
- `resolvePrimaryConfig()` reads `Singleton.INST.get(AiCommonConfig.class)`.
- `shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-proxy/src/main/java/org/apache/shenyu/plugin/ai/proxy/enhanced/handler/AiProxyPluginHandler.java`
- `handlerPlugin()` does not populate global plugin configuration.
- `shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-proxy/src/main/java/org/apache/shenyu/plugin/ai/proxy/enhanced/AiProxyPlugin.java`
- `createChatModel()` hard-fails when required provider/factory config is missing.

Contributor guide

No contributing guide indexed for this repository

Research direction

Read AiProxyConfigService.resolvePrimaryConfig(), AiProxyPluginHandler.handlerPlugin(), and AiProxyPlugin.createChatModel() to trace how plugin-level configuration reaches runtime resolution. Determine which of the two expected approaches fits the existing flow. Done means shared AI proxy defaults configured at plugin/global level are applied, or the runtime no longer depends on that merge path, without incomplete provider configuration failures.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
api, backend
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
55/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.