The best way to control Claude Code, Codex and more from any computer or phone
fix(provider-cursor): Cursor sign-in shows why it failed (#25938)
Julius Marminge committed
Nov 11, 2026 at 15:46 UTC
bd5ed4dac8a7fcec1f9670284637788aad3c9439
2 files changed
+50
-7
packages/provider-cursor/src/server/auth.test.ts
+34
-5
@@ -4,18 +4,20 @@ import * as NodeServices from "@effect/platform-node/NodeServices";
4
import * as Layer from "effect/Layer";
5
import { expect, it } from "@effect/vitest";
6
import { ProviderInstanceId, ProviderSetupError, type ProviderAuthState } from "@t3tools/contracts";
7
+import * as Cause from "effect/Cause";
8
import * as Clock from "effect/Clock";
9
import * as Deferred from "effect/Deferred";
10
import * as Effect from "effect/Effect";
11
import * as Exit from "effect/Exit";
12
import * as Fiber from "effect/Fiber";
13
+import * as Logger from "effect/Logger";
14
import * as Option from "effect/Option";
15
import * as Stream from "effect/Stream";
16
17
import { makeCursorAuth, type CursorAuthOptions } from "./auth.ts";
18
import { loadCursorSdk } from "./sdk.ts";
19
18
-const { InMemoryCredentialStore } = loadCursorSdk();
20
+const { AuthenticationError, InMemoryCredentialStore } = loadCursorSdk();
21
22
const instanceId = ProviderInstanceId.make("cursor-personal");
23
const owner = "owner-client";
@@ -73,6 +75,13 @@ const makeHarness = Effect.fn("makeCursorAuthHarness")(function* (
75
};
76
});
77
78
+const captureWarnings = (warnings: string[]) =>
79
+ Logger.layer([
80
+ Logger.make(({ logLevel, cause }) => {
81
+ if (logLevel === "Warn") warnings.push(Cause.pretty(cause));
82
+ }),
83
+ ]);
84
+
85
type Auth = Effect.Success<ReturnType<typeof makeCursorAuth>>;
86
const phase = (auth: Auth, phase: ProviderAuthState["phase"], session = owner) =>
87
auth.controller.subscribe(session).pipe(
@@ -171,8 +180,9 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("CursorAuth", (it
180
}).pipe(Effect.scoped),
181
);
182
174
- it.effect("aborts cancellation and ignores a late successful SDK login", () =>
175
- Effect.gen(function* () {
183
+ it.effect("aborts cancellation and ignores a late successful SDK login", () => {
184
+ const warnings: string[] = [];
185
+ return Effect.gen(function* () {
186
const harness = yield* makeHarness();
187
yield* harness.auth.controller.start(owner);
188
const waiting = yield* phase(harness.auth, "waiting");
@@ -184,8 +194,9 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("CursorAuth", (it
194
yield* Effect.promise(() => harness.returned.promise);
195
expect(yield* harness.auth.readApiKey).toBeUndefined();
196
expect(harness.changes).toEqual([]);
187
- }).pipe(Effect.scoped),
188
- );
197
+ expect(warnings).toEqual([]);
198
+ }).pipe(Effect.scoped, Effect.provide(captureWarnings(warnings)));
199
+ });
200
201
it.effect("discards a credential rejected by verification and permits a fresh login", () =>
202
Effect.gen(function* () {
@@ -219,6 +230,24 @@ it.layer(Layer.mergeAll(NodeServices.layer, NodeCrypto.layer))("CursorAuth", (it
230
}).pipe(Effect.scoped),
231
);
232
233
+ it.effect("shows a fixed reason when browser login fails and logs the SDK cause", () => {
234
+ const warnings: string[] = [];
235
+ return Effect.gen(function* () {
236
+ const sdkMessage =
237
+ "Login succeeded, but creating an SDK API key failed: [permission_denied] user API keys are disabled for this team (your team's settings may restrict user API keys — ask a team admin, or pass an existing API key directly)";
238
+ const harness = yield* makeHarness({
239
+ login: () => Promise.reject(new AuthenticationError(sdkMessage)),
240
+ });
241
+ yield* harness.auth.controller.start(owner);
242
+ const failed = yield* phase(harness.auth, "failed");
243
+ expect(failed.message).toContain("could not create an API key");
244
+ expect(failed.message).not.toContain("permission_denied");
245
+ expect(yield* harness.auth.readApiKey).toBeUndefined();
246
+ expect(warnings).toHaveLength(1);
247
+ expect(warnings[0]).toContain(sdkMessage);
248
+ }).pipe(Effect.scoped, Effect.provide(captureWarnings(warnings)));
249
+ });
250
+
251
it.effect("clears only this instance's credential after its sessions stop", () =>
252
Effect.gen(function* () {
253
const harness = yield* makeHarness();
packages/provider-cursor/src/server/auth.ts
+16
-2
@@ -18,11 +18,24 @@ import * as Semaphore from "effect/Semaphore";
18
import * as Stream from "effect/Stream";
19
import * as SubscriptionRef from "effect/SubscriptionRef";
20
21
-import { loadCursorSdk } from "./sdk.ts";
21
+import { isCursorSdkError, loadCursorSdk } from "./sdk.ts";
22
import type { ProviderAuthController } from "@t3tools/provider-core/server/auth";
23
24
const AUTH_TIMEOUT_MS = 300_000;
25
26
+// The SDK has no code distinguishing these failures, so classify by its fixed message prefixes.
27
+const loginFailureDetail = (cause: unknown) => {
28
+ if (isCursorSdkError(cause, "CursorSdkError")) {
29
+ if (cause.message.startsWith("Login succeeded, but creating an SDK API key failed")) {
30
+ return "Cursor signed you in but could not create an API key. Your team's settings may restrict API keys: ask a team admin, or add CURSOR_API_KEY in provider settings.";
31
+ }
32
+ if (cause.message.startsWith("Login failed or timed out")) {
33
+ return "Cursor sign-in failed or timed out. Check that this machine can reach Cursor, then start sign-in again.";
34
+ }
35
+ }
36
+ return "Cursor sign-in failed. Start sign-in again.";
37
+};
38
+
39
interface AuthFlow {
40
readonly id: string;
41
readonly owner: string;
@@ -204,7 +217,7 @@ export const makeCursorAuth = Effect.fn("makeCursorAuth")(function* (options: Cu
217
new ProviderSetupError({
218
instanceId: options.instanceId,
219
operation: "start",
207
- detail: "Cursor sign-in failed. Start sign-in again.",
220
+ detail: loginFailureDetail(cause),
221
cause,
222
}),
223
});
@@ -270,6 +283,7 @@ export const makeCursorAuth = Effect.fn("makeCursorAuth")(function* (options: Cu
283
}),
284
),
285
}),
286
+ Effect.tapCause((cause) => Effect.logWarning("Cursor sign-in failed", cause)),
287
Effect.exit,
288
Effect.flatMap((result) =>
289
lock.withPermits(1)(