From b2f0d42394205cfc18a5ed975d5c5eeacd0bcd89 Mon Sep 17 00:00:00 2001 From: ZeyuFu Date: Sun, 17 May 2026 10:37:40 -0400 Subject: [PATCH] test(runtime-fallback): tighten quota regression fixtures so new paths actually fire Addresses cubic-dev-ai bot review on #4113 (P2): the RESOURCE_EXHAUSTED and snake_case insufficient_quota fixtures contained quota-shaped messages that already matched pre-existing message regexes, so the tests passed even without the new errorName allow-list entry and the underscore normalization respectively. Replace both fixture messages with a generic "Request failed." so the only path to a `quota_exceeded` classification is via the new code: - RESOURCE_EXHAUSTED: only the new `errorName?.includes("resourceexhausted")` match on the normalized name can fire. - insufficient_quota (snake_case): only the new underscore-stripping normalization can route the name to `insufficientquota` and match the existing allow-list entry. The third new test (Google ResourceExhausted message-only) is unchanged because its message uniquely matches only the new `/resource.?exhausted/i` pattern and not any existing quota regex. Co-Authored-By: Claude Opus 4.7 (1M context) --- .../quota-error-classifier.regression.test.ts | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/hooks/runtime-fallback/quota-error-classifier.regression.test.ts b/src/hooks/runtime-fallback/quota-error-classifier.regression.test.ts index 1a26bfb89..9657af523 100644 --- a/src/hooks/runtime-fallback/quota-error-classifier.regression.test.ts +++ b/src/hooks/runtime-fallback/quota-error-classifier.regression.test.ts @@ -90,11 +90,14 @@ describe("runtime-fallback quota error regressions", () => { expect(retryable).toBe(true) }) - test("classifies Google RESOURCE_EXHAUSTED (gRPC code 8) as quota_exceeded", () => { + test("classifies Google RESOURCE_EXHAUSTED (gRPC code 8) as quota_exceeded via error name only", () => { //#given + // Bare provider error: only the error name carries the quota signal. + // Message is intentionally generic so the test fails if the new + // `resourceexhausted` name allow-list entry is removed. const error = { name: "RESOURCE_EXHAUSTED", - message: "Quota exceeded for quota metric 'Generate Content' and limit 'Generate Content quota per minute'.", + message: "Request failed.", } //#when @@ -122,11 +125,14 @@ describe("runtime-fallback quota error regressions", () => { expect(retryable).toBe(true) }) - test("classifies snake_case OpenAI insufficient_quota error name as quota_exceeded", () => { + test("classifies snake_case OpenAI insufficient_quota error name as quota_exceeded via name only", () => { //#given + // Bare provider error: only the snake_case error name carries the quota signal. + // Message is intentionally generic so the test fails if the underscore + // normalization (`insufficient_quota` -> `insufficientquota`) regresses. const error = { name: "insufficient_quota", - message: "You exceeded your current quota, please check your plan and billing details.", + message: "Request failed.", } //#when