Skip to content

Commit 19801d2

Browse files
juncursoragent
authored andcommitted
fix(cursor): classify failed_precondition as a non-retryable invalid request
A plan-gated model invoked on a plan without it (live: cursor/claude-fable-5) is rejected with "Cursor Connect error failed_precondition", which fell through to "Cursor upstream error" (502) — a transient status the Claude inbound then surfaced as a retryable 529 overloaded_error. gRPC FAILED_PRECONDITION is deterministic and non-retryable by definition, so classify it as "Cursor invalid request" (400) and let the client see the real verdict immediately. Co-authored-by: Cursor <[email protected]>
1 parent 88d1da6 commit 19801d2

2 files changed

Lines changed: 18 additions & 0 deletions

File tree

‎src/adapters/cursor/cursor-errors.ts‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,14 @@ export function classifyCursorError(message: string, sizeContext?: CursorSizeCon
248248
lower.includes("server is busy")
249249
) return "Cursor server overloaded";
250250

251+
// gRPC FAILED_PRECONDITION is deterministic and non-retryable (unlike UNAVAILABLE):
252+
// the backend rejected the call because the account/plan state does not allow it —
253+
// seen live when a plan-gated model (e.g. claude-fable-5) runs on a plan without it.
254+
// Leaving it as "Cursor upstream error" (502) made clients retry it as overload.
255+
if (lower.includes("failed_precondition") || lower.includes("failed precondition")) {
256+
return "Cursor invalid request";
257+
}
258+
251259
if (
252260
lower.includes("invalid") ||
253261
lower.includes("not found") ||

‎tests/cursor-errors.test.ts‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import {
55
isCursorInvalidArgumentError,
66
safeCursorErrorMessage,
77
} from "../src/adapters/cursor/cursor-errors";
8+
import { inferHttpStatusFromAdapterMessage } from "../src/lib/errors";
89

910
describe("classifyCursorError", () => {
1011
test("rate limit and resource exhaustion stay distinct", () => {
@@ -59,6 +60,15 @@ describe("classifyCursorError", () => {
5960
expect(classifyCursorError("invalid request: malformed tool schema")).toBe("Cursor invalid request");
6061
});
6162

63+
test("failed_precondition is a deterministic non-retryable rejection, not overload", () => {
64+
// Live evidence: a plan-gated model (claude-fable-5) invoked on a plan without it
65+
// returns "Cursor Connect error failed_precondition: Error". gRPC FAILED_PRECONDITION
66+
// is non-retryable by definition; as "Cursor upstream error" (502) clients retried it
67+
// as overload, and the Claude inbound surfaced it as a misleading 529.
68+
expect(classifyCursorError("Cursor Connect error failed_precondition: Error")).toBe("Cursor invalid request");
69+
expect(inferHttpStatusFromAdapterMessage("Cursor invalid request: Cursor Connect error failed_precondition: Error")).toBe(400);
70+
});
71+
6272
test("timeout / deadline", () => {
6373
expect(classifyCursorError("Cursor transport timed out before first response")).toBe("Cursor request timed out");
6474
expect(classifyCursorError("deadline exceeded")).toBe("Cursor request timed out");

0 commit comments

Comments
 (0)