Skip to content

Commit 3ad3f85

Browse files
only21milclaude
andcommitted
fix(provider-cursor): any 403 on /v1/me except plan_required skips the account read
The SDK sets code "unknown" when a 403 body carries no code, so matching only feature_unavailable would undo the #16224 fix if Cursor's real Enterprise body lacks it. plan_required still fails, and so do 401, network and server errors. New status rows cover a codeless 403, a plan_required 403 and a 503 on /v1/me. Co-Authored-By: Claude Opus 5.5 <[email protected]>
1 parent fab4a6e commit 3ad3f85

2 files changed

Lines changed: 45 additions & 6 deletions

File tree

‎packages/provider-cursor/src/server/CursorSdkCatalog.ts‎

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,13 @@ export class CursorSdkCatalogError extends Schema.TaggedError<CursorSdkCatalogEr
3131
return this.cause instanceof CursorSdkError && this.cause.code === "plan_required";
3232
}
3333

34-
get featureUnavailable(): boolean {
35-
return this.cause instanceof CursorSdkError && this.cause.code === "feature_unavailable";
34+
// The SDK sets code "unknown" when a 403 body has no code, so any 403 except
35+
// plan_required counts as blocked, not only feature_unavailable.
36+
get accountBlocked(): boolean {
37+
if (!(this.cause instanceof CursorSdkError)) return false;
38+
return (
39+
this.cause.code === "feature_unavailable" || (this.cause.status === 403 && !this.planRequired)
40+
);
3641
}
3742
}
3843

@@ -86,14 +91,14 @@ export const makeCursorSdkCatalog = Effect.fn("CursorSdkCatalog.make")(function*
8691
read: (apiKey) =>
8792
Effect.all(
8893
{
89-
// Enterprise teams can block /v1/me while models and local runs work.
90-
// The key name and email only label the account, so that block alone
91-
// does not fail the read. Other /v1/me failures still do.
94+
// Enterprise teams can block /v1/me with a 403 while models and local
95+
// runs work. The key name and email only label the account, so that
96+
// block alone does not fail the read. Other /v1/me failures still do.
9297
user: probes
9398
.readUser(apiKey)
9499
.pipe(
95100
Effect.catch((error) =>
96-
error.featureUnavailable ? Effect.undefined : Effect.fail(error),
101+
error.accountBlocked ? Effect.undefined : Effect.fail(error),
97102
),
98103
),
99104
models: Cache.get(modelCache, apiKey),

‎packages/provider-cursor/src/server/status.test.ts‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,40 @@ describe("checkCursorProviderStatus", () => {
274274
models: [{ slug: "claude-opus-4-8", isCustom: false }],
275275
},
276276
},
277+
{
278+
name: "keeps models when /v1/me returns a 403 without a code",
279+
meFailure: new CursorSdkError("[unknown] Forbidden", { code: "unknown", status: 403 }),
280+
expected: {
281+
status: "ready",
282+
auth: { status: "authenticated", type: "api-key", label: "Cursor API key" },
283+
models: [{ slug: "claude-opus-4-8", isCustom: false }],
284+
},
285+
},
286+
{
287+
name: "keeps the paid-plan message when /v1/me returns plan_required",
288+
meFailure: new CursorSdkError("[plan_required] Not available for free users.", {
289+
code: "plan_required",
290+
status: 403,
291+
}),
292+
expected: {
293+
status: "error",
294+
auth: { status: "unknown" },
295+
message:
296+
"Cursor needs a paid plan to run in T3 Code. Upgrade the account that owns CURSOR_API_KEY or use a key from a paid account.",
297+
},
298+
},
299+
{
300+
name: "fails when /v1/me has a server error",
301+
meFailure: new CursorSdkError("[unknown] Service unavailable", {
302+
code: "unknown",
303+
status: 503,
304+
}),
305+
expected: {
306+
status: "error",
307+
auth: { status: "unknown" },
308+
message: "Cursor SDK catalog request failed. Check server logs for details.",
309+
},
310+
},
277311
{
278312
name: "fails a key that /v1/me rejects",
279313
meFailure: new CursorSdkError("Unauthorized", { status: 401 }),

0 commit comments

Comments
 (0)