Skip to content

[Bug]: ChatGPT sign-in returns silently when its environment has been removed #39572

Done

Description

@StiensWout

Before submitting

  • I searched existing issues and did not find a duplicate.
  • I included enough detail to reproduce or investigate the problem.

Area

apps/web

Steps to reproduce

  1. Start ChatGPT sign-in for a remote environment from the web app’s Welcome page.
  2. Under Other ways to connect, choose Use T3 desktop for automatic return.
  3. In another tab in the same browser, remove that environment from this device while the sign-in page is open.
  4. Finish signing in on OpenAI’s page.

Expected behavior

T3 Code tells you that sign-in could not finish because the destination environment is unavailable.

Actual behavior

T3 Code opens Welcome for another environment without reporting that the sign-in failed.

return to removed environment

failure

Impact

Minor bug or occasional failure. People who finish sign-in after removing the destination are left without a way to tell why their account never connected.

Version or commit

main at 59651c1761. The cause is at apps/web/src/providerAuthDelivery.ts:33.

Environment

Linux x64 boat.dev default machine, a fresh checkout.

Logs or stack traces

ChatGPT sign-in couldn't finish
Automated repro

Fails in 2 of 2 runs on main: apply the patch with git apply, then run the command.

diff --git a/scripts/scenarios/chatgpt-return-reports-removed-environment.e2e.ts b/scripts/scenarios/chatgpt-return-reports-removed-environment.e2e.ts
new file mode 100644
index 0000000000..4fdd05252d
--- /dev/null
+++ b/scripts/scenarios/chatgpt-return-reports-removed-environment.e2e.ts
@@ -0,0 +1,52 @@
+import { EnvironmentId, ProviderInstanceId } from "@t3tools/contracts";
+import { codexAuthDeliveryUrl } from "@t3tools/shared/codexAuthHandoff";
+import { expect } from "e2e";
+
+import { test, WEB } from "./t3.ts";
+
+test(
+  "A ChatGPT sign-in return reports that it cannot finish on a removed environment",
+  WEB,
+  async ({ t3, app, screen }) => {
+    await t3.project("demo");
+    const environmentId = EnvironmentId.make("removed-sign-in-machine");
+    const instanceId = ProviderInstanceId.make("codex");
+    const returnUrl = new URL("/welcome", app.baseUrl);
+    returnUrl.hash = `agents:${environmentId}`;
+
+    // Start at the helper's return link. The missing machine makes the code unusable,
+    // so this does not contact the identity provider.
+    const callback = new URL("http://127.0.0.1:1455/auth/callback");
+    callback.searchParams.set("state", "scenario-auth-state");
+    const authorization = new URL("https://auth.openai.com/api/accounts/authorize");
+    authorization.search = new URLSearchParams({
+      state: "scenario-auth-state",
+      redirect_uri: "http://127.0.0.1:1455/auth/callback",
+      response_type: "code",
+      code_challenge_method: "S256",
+      code_challenge: "a".repeat(43),
+      client_id: "dynamic_agent_client",
+    }).toString();
+    callback.searchParams.set("code", "scenario-code");
+    const delivery = new URL(
+      codexAuthDeliveryUrl(
+        {
+          authorizationUrl: authorization.href,
+          returnUrl: returnUrl.href,
+          environmentId,
+          instanceId,
+          flowId: "scenario-flow",
+        },
+        callback.href,
+      ),
+    );
+    await t3.open(`${delivery.pathname}${delivery.search}${delivery.hash}`);
+    try {
+      await expect(
+        screen.getByText("ChatGPT sign-in couldn't finish", { exact: true }),
+      ).toBeVisible();
+    } finally {
+      await app.screenshot("return-to-removed-environment");
+    }
+  },
+);
pnpm scenarios:prove scripts/scenarios/chatgpt-return-reports-removed-environment.e2e.ts --base main

Workaround

No response

Activity

  1. added
    vouch:trusted
    on Nov 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    vouch:trusted

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions