Skip to content

Commit fa71942

Browse files
committed
fix(antigravity): distinguish session initialization auth failures
1 parent 2fb99a7 commit fa71942

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

‎apps/server/src/provider/AntigravityAuth.test.ts‎

Lines changed: 28 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ const makeHarness = Effect.fn("makeAuthTestHarness")(function* (
6161
} = {},
6262
) {
6363
const authenticated = yield* Deferred.make<void, AcpErrors.AcpError>();
64-
const discovered = yield* Deferred.make<void>();
64+
const discovered = yield* Deferred.make<void, AcpErrors.AcpError>();
6565
const closed = yield* Deferred.make<void>();
6666
const events: string[] = [];
6767
let receiveAuthorizationUrl:
@@ -224,6 +224,33 @@ it.layer(NodeServices.layer)("AntigravityAuth", (it) => {
224224
}),
225225
);
226226

227+
it.effect(
228+
"distinguishes a post-authentication session failure without exposing its payload",
229+
() =>
230+
Effect.gen(function* () {
231+
const harness = yield* makeHarness();
232+
yield* harness.auth.controller.start(owner);
233+
yield* phase(harness.auth, "waiting");
234+
yield* Deferred.succeed(harness.authenticated, undefined);
235+
yield* Deferred.fail(
236+
harness.discovered,
237+
new AcpErrors.AcpRequestError({
238+
code: -32603,
239+
errorMessage: `Internal error ${callbackUrl}`,
240+
method: "session/new",
241+
}),
242+
);
243+
const failed = yield* phase(harness.auth, "failed");
244+
assert.equal(
245+
failed.message,
246+
"Antigravity authenticated, but could not initialize a session or load models.",
247+
);
248+
assert.isNull(failed.authorizationUrl);
249+
assert.deepEqual(harness.catalog(), ["previous-account-model"]);
250+
yield* Deferred.await(harness.closed);
251+
}),
252+
);
253+
227254
it.effect("does not call callback HTTP success a successful Google sign-in", () =>
228255
Effect.gen(function* () {
229256
const harness = yield* makeHarness();

‎apps/server/src/provider/AntigravityAuth.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,9 @@ function safeAuthFailure(cause: Cause.Cause<unknown>, usesBrowser: boolean): str
114114
if (/access_denied|denied access|cancelled/i.test(error.value.errorMessage)) {
115115
return "Google sign-in was not approved. Start sign-in again.";
116116
}
117+
if (error.value.method === "session/new" && error.value.code === -32603) {
118+
return "Antigravity authenticated, but could not initialize a session or load models.";
119+
}
117120
if (!usesBrowser && error.value.code === -32602) {
118121
return "Antigravity rejected the configured credentials. Check the provider settings.";
119122
}

0 commit comments

Comments
 (0)