From 691b29da7ee48355fc56212f622548b1e2cd0a41 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E9=BB=84=E8=87=AA=E8=BE=BE?= <980324341@qq.com> Date: Wed, 11 Nov 2026 18:15:41 +0800 Subject: [PATCH] =?UTF-8?q?fix(llm):=20=E8=AF=86=E5=88=AB=E9=92=B1?= =?UTF-8?q?=E5=8C=85=E5=9E=8B=E6=AC=A0=E8=B4=B9=20insufficient=5Ffunds?= =?UTF-8?q?=EF=BC=8C=E6=AC=A0=E8=B4=B9=E4=B8=8D=E5=86=8D=E8=90=BD=E5=9B=9E?= =?UTF-8?q?=E6=9C=AA=E5=AE=8C=E6=88=90=E6=A3=80=E6=B5=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aiimage/common/retry/LlmBalanceGuard.java | 5 +++++ .../common/retry/LlmBalanceGuardTest.java | 16 ++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/backend-java/src/main/java/com/nanri/aiimage/common/retry/LlmBalanceGuard.java b/backend-java/src/main/java/com/nanri/aiimage/common/retry/LlmBalanceGuard.java index a42bed790..7c79099a7 100644 --- a/backend-java/src/main/java/com/nanri/aiimage/common/retry/LlmBalanceGuard.java +++ b/backend-java/src/main/java/com/nanri/aiimage/common/retry/LlmBalanceGuard.java @@ -34,6 +34,11 @@ public final class LlmBalanceGuard { "insufficient_user_quota", "insufficient_quota", "insufficient balance", + // 2026-11-11 现网:钱包型欠费走 insufficient_funds + "wallet balance insufficient", + // 与上面两条的拼写与词序都不同("balance insufficient" 里没有连续的 "insufficient balance"), + // 漏掉这两个锚点,欠费就会一路落回"未完成检测/上游不可用",用户根本看不到"欠费"。 + "insufficient_funds", + "wallet balance insufficient", "预扣费额度失败", "额度不足", "余额不足", diff --git a/backend-java/src/test/java/com/nanri/aiimage/common/retry/LlmBalanceGuardTest.java b/backend-java/src/test/java/com/nanri/aiimage/common/retry/LlmBalanceGuardTest.java index 37b230a90..fa20ae5b3 100644 --- a/backend-java/src/test/java/com/nanri/aiimage/common/retry/LlmBalanceGuardTest.java +++ b/backend-java/src/test/java/com/nanri/aiimage/common/retry/LlmBalanceGuardTest.java @@ -30,6 +30,22 @@ class LlmBalanceGuardTest { assertThat(LlmBalanceGuard.isQuotaExhausted(wrapped)).isTrue(); } + /** + * 2026-11-11 现网原文(A 机 java-server,12 小时 3737 次,界面仍显示"未完成检测"): + * 这一家的钱包欠费用的是 {@code insufficient_funds} 与 {@code wallet balance insufficient}, + * 与上面那条 403 的 {@code insufficient_user_quota} / {@code insufficient balance} 拼写与词序都不同, + * 旧词表一条都命中不了 ⇒ 用户完全看不到"欠费"这两个字。 + */ + @Test + void detectsObservedWalletBalanceBody() { + IllegalStateException observed = new IllegalStateException( + "LLM http 402: {\"error\":{\"code\":\"insufficient_funds\",\"message\":\"wallet balance " + + "insufficient for chat gm-3.5-flash-lite (本次需预留约 ⚡0.02)\"," + + "\"type\":\"insufficient_funds\"}}"); + + assertThat(LlmBalanceGuard.isQuotaExhausted(observed)).isTrue(); + } + @Test void transientFailuresAreNotQuotaExhaustion() { assertThat(LlmBalanceGuard.isQuotaExhausted(new IllegalStateException("LLM http 502: bad gateway"))).isFalse();