From a9d0d92f20828bc61e781063343aaafff5187ce7 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Mon, 27 Jul 2026 18:24:57 +0100 Subject: [PATCH 1/3] fix(coderd/x/chatd/chaterror): classify aibridge 403 as ChatErrorKindUsageLimit --- coderd/x/chatd/chaterror/classify_test.go | 1 + coderd/x/chatd/chaterror/signals.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/coderd/x/chatd/chaterror/classify_test.go b/coderd/x/chatd/chaterror/classify_test.go index 2ab7549e59e..5592a57b9d2 100644 --- a/coderd/x/chatd/chaterror/classify_test.go +++ b/coderd/x/chatd/chaterror/classify_test.go @@ -503,6 +503,7 @@ func TestClassify_PatternCoverage(t *testing.T) { {name: "QuotaLiteral", err: "quota", wantKind: codersdk.ChatErrorKindUsageLimit, wantRetry: false}, {name: "BillingLiteral", err: "billing", wantKind: codersdk.ChatErrorKindUsageLimit, wantRetry: false}, {name: "InsufficientQuotaLiteral", err: "insufficient_quota", wantKind: codersdk.ChatErrorKindUsageLimit, wantRetry: false}, + {name: "AIBudgetLiteral", err: "status 429: AI budget of US$10.00 exceeded", wantKind: codersdk.ChatErrorKindUsageLimit, wantRetry: false}, {name: "PaymentRequiredLiteral", err: "payment required", wantKind: codersdk.ChatErrorKindUsageLimit, wantRetry: false}, {name: "ForbiddenLiteral", err: "forbidden", wantKind: codersdk.ChatErrorKindAuth, wantRetry: false}, {name: "InvalidModelLiteral", err: "invalid model", wantKind: codersdk.ChatErrorKindConfig, wantRetry: false}, diff --git a/coderd/x/chatd/chaterror/signals.go b/coderd/x/chatd/chaterror/signals.go index 4f004e150be..c495f18baae 100644 --- a/coderd/x/chatd/chaterror/signals.go +++ b/coderd/x/chatd/chaterror/signals.go @@ -73,7 +73,7 @@ var ( } // Hard usage exhaustion codes that fire at any HTTP status, // including 429. - usageLimitAnyStatusPatterns = []string{"insufficient_quota"} + usageLimitAnyStatusPatterns = []string{"insufficient_quota", "ai budget"} configPatterns = []string{ "invalid model", "model not found", From f3fab013c2c1bff1cd265aaa9f193f03e0bc74c8 Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Mon, 27 Jul 2026 18:33:51 +0100 Subject: [PATCH 2/3] Potential fix for pull request finding Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- coderd/x/chatd/chaterror/classify_test.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/coderd/x/chatd/chaterror/classify_test.go b/coderd/x/chatd/chaterror/classify_test.go index 5592a57b9d2..2db9ab5a1a4 100644 --- a/coderd/x/chatd/chaterror/classify_test.go +++ b/coderd/x/chatd/chaterror/classify_test.go @@ -503,7 +503,8 @@ func TestClassify_PatternCoverage(t *testing.T) { {name: "QuotaLiteral", err: "quota", wantKind: codersdk.ChatErrorKindUsageLimit, wantRetry: false}, {name: "BillingLiteral", err: "billing", wantKind: codersdk.ChatErrorKindUsageLimit, wantRetry: false}, {name: "InsufficientQuotaLiteral", err: "insufficient_quota", wantKind: codersdk.ChatErrorKindUsageLimit, wantRetry: false}, - {name: "AIBudgetLiteral", err: "status 429: AI budget of US$10.00 exceeded", wantKind: codersdk.ChatErrorKindUsageLimit, wantRetry: false}, + {name: "AIBudgetExceededLiteral", err: "status 403: AI budget of US$10.00 exceeded", wantKind: codersdk.ChatErrorKindUsageLimit, wantRetry: false}, + {name: "AIBudgetCheckFailedLiteral", err: "status 500: internal server error checking user AI budget", wantKind: codersdk.ChatErrorKindGeneric, wantRetry: true}, {name: "PaymentRequiredLiteral", err: "payment required", wantKind: codersdk.ChatErrorKindUsageLimit, wantRetry: false}, {name: "ForbiddenLiteral", err: "forbidden", wantKind: codersdk.ChatErrorKindAuth, wantRetry: false}, {name: "InvalidModelLiteral", err: "invalid model", wantKind: codersdk.ChatErrorKindConfig, wantRetry: false}, From b55ff0bbfe38c8b3564e59104c98c7c49bd1716d Mon Sep 17 00:00:00 2001 From: Cian Johnston Date: Mon, 27 Jul 2026 18:39:55 +0100 Subject: [PATCH 3/3] be more specific --- coderd/x/chatd/chaterror/signals.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/coderd/x/chatd/chaterror/signals.go b/coderd/x/chatd/chaterror/signals.go index c495f18baae..15f439df3ef 100644 --- a/coderd/x/chatd/chaterror/signals.go +++ b/coderd/x/chatd/chaterror/signals.go @@ -73,7 +73,7 @@ var ( } // Hard usage exhaustion codes that fire at any HTTP status, // including 429. - usageLimitAnyStatusPatterns = []string{"insufficient_quota", "ai budget"} + usageLimitAnyStatusPatterns = []string{"insufficient_quota", "ai budget of"} configPatterns = []string{ "invalid model", "model not found",