This is an automated email from the ASF dual-hosted git repository.
Aias00 pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/shenyu.git
The following commit(s) were added to refs/heads/master by this push:
new e60912303f [type:bug] Fix AiProxy forwarding internal fallbackConfig
to upstream (#7020) (#7024)
e60912303f is described below
commit e60912303fdbf3927665181f047db1169bf6f8a0
Author: Arvin <[email protected]>
AuthorDate: Wed Sep 2 16:40:29 2026 +0800
[type:bug] Fix AiProxy forwarding internal fallbackConfig to upstream
(#7020) (#7024)
Co-authored-by: aias00 <[email protected]>
---
.../plugin/ai/proxy/enhanced/service/AiProxyConfigService.java | 6 ++++++
.../plugin/ai/proxy/enhanced/service/AiProxyConfigServiceTest.java | 4 +++-
2 files changed, 9 insertions(+), 1 deletion(-)
diff --git
a/shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-proxy/src/main/java/org/apache/shenyu/plugin/ai/proxy/enhanced/service/AiProxyConfigService.java
b/shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-proxy/src/main/java/org/apache/shenyu/plugin/ai/proxy/enhanced/service/AiProxyConfigService.java
index 0092375add..041727fa41 100644
---
a/shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-proxy/src/main/java/org/apache/shenyu/plugin/ai/proxy/enhanced/service/AiProxyConfigService.java
+++
b/shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-proxy/src/main/java/org/apache/shenyu/plugin/ai/proxy/enhanced/service/AiProxyConfigService.java
@@ -18,6 +18,7 @@
package org.apache.shenyu.plugin.ai.proxy.enhanced.service;
import com.fasterxml.jackson.databind.JsonNode;
+import com.fasterxml.jackson.databind.node.ObjectNode;
import org.apache.shenyu.common.dto.convert.rule.AiProxyHandle;
import org.apache.shenyu.common.utils.JsonUtils;
import org.apache.shenyu.common.utils.Singleton;
@@ -123,6 +124,11 @@ public class AiProxyConfigService {
if (jsonNode.has("content")) {
return jsonNode.get("content").asText();
}
+ // Strip internal fallbackConfig from body before forwarding to
upstream
+ if (jsonNode.has(FALLBACK_CONFIG) && jsonNode.isObject()) {
+ ((ObjectNode) jsonNode).remove(FALLBACK_CONFIG);
+ return jsonNode.toString();
+ }
} catch (Exception e) {
// ignore parsing errors and fall back to original body
}
diff --git
a/shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-proxy/src/test/java/org/apache/shenyu/plugin/ai/proxy/enhanced/service/AiProxyConfigServiceTest.java
b/shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-proxy/src/test/java/org/apache/shenyu/plugin/ai/proxy/enhanced/service/AiProxyConfigServiceTest.java
index 79b1a47447..6381c8a87e 100644
---
a/shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-proxy/src/test/java/org/apache/shenyu/plugin/ai/proxy/enhanced/service/AiProxyConfigServiceTest.java
+++
b/shenyu-plugin/shenyu-plugin-ai/shenyu-plugin-ai-proxy/src/test/java/org/apache/shenyu/plugin/ai/proxy/enhanced/service/AiProxyConfigServiceTest.java
@@ -195,7 +195,9 @@ public class AiProxyConfigServiceTest {
void testExtractPromptWithFallbackConfigButNoPromptOrContent() {
String requestBody = "{\"fallbackConfig\": {\"model\":
\"test-model\"}, \"messages\": [{\"role\": \"user\"}]}";
String result = configService.extractPrompt(requestBody);
- assertEquals(requestBody, result);
+ // fallbackConfig should be stripped before forwarding to upstream
+ assertFalse(result.contains("fallbackConfig"));
+ assertTrue(result.contains("messages"));
}
@Test