{"record":{"id":"0536c9771519fe66","repo":"zed-industries/zed","slug":"oauth-callback-was-cancelled","errorCode":null,"errorMessage":"OAuth callback was cancelled","messagePattern":"OAuth callback was cancelled","errorType":"exception","errorClass":"anyhow::Error","httpStatus":null,"severity":"error","filePath":"crates/openai_subscribed/src/openai_subscribed.rs","lineNumber":1166,"sourceCode":"    let mut auth_url = url::Url::parse(OPENAI_AUTHORIZE_URL).expect(\"valid base URL\");\n    auth_url\n        .query_pairs_mut()\n        .append_pair(\"client_id\", CLIENT_ID)\n        .append_pair(\"redirect_uri\", &redirect_uri)\n        // Deliberately excludes `api.connectors.read api.connectors.invoke`\n        // (which Codex CLI requests): extra scopes inflate the\n        // access-token JWT, and the serialized credentials must fit within\n        // Windows Credential Manager's 2560-byte blob limit\n        // (CRED_MAX_CREDENTIAL_BLOB_SIZE). See #58541.\n        .append_pair(\"scope\", \"openid profile email offline_access\")\n        .append_pair(\"response_type\", \"code\")\n        .append_pair(\"code_challenge\", &challenge)\n        .append_pair(\"code_challenge_method\", \"S256\")\n        .append_pair(\"id_token_add_organizations\", \"true\")\n        .append_pair(\"state\", &oauth_state)\n        .append_pair(\"codex_cli_simplified_flow\", \"true\")\n        .append_pair(\"originator\", \"zed\");\n\n    // Open browser AFTER the listener is ready\n    cx.update(|cx| cx.open_url(auth_url.as_str()));\n\n    // Await the callback\n    let callback = callback_rx\n        .await\n        .map_err(|_| anyhow!(\"OAuth callback was cancelled\"))?\n        .context(\"OAuth callback failed\")?;\n\n    // Validate CSRF state\n    if callback.state != oauth_state {\n        return Err(anyhow!(\"OAuth state mismatch\"));\n    }\n\n    let tokens = exchange_code(&http_client, &callback.code, &verifier, &redirect_uri)\n        .await\n        .context(\"Token exchange failed\")?;\n","sourceCodeStart":1148,"sourceCodeEnd":1184,"githubUrl":"https://github.com/zed-industries/zed/blob/5a9b9558db01a6b906cec2fb70a797affdc58cdd/crates/openai_subscribed/src/openai_subscribed.rs#L1148-L1184","documentation":"The one-shot channel carrying the OAuth callback result was dropped before a callback arrived — the local HTTP listener or the awaiting task was cancelled (e.g. the flow was aborted, the app shut down, or the listener socket closed) so the receiver got None.","triggerScenarios":"Thrown at crates/openai_subscribed/src/openai_subscribed.rs:1134 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Restart the sign-in flow to spawn a fresh callback listener","Check that another process or a previous sign-in attempt is not occupying the loopback redirect port","Ensure browsers can reach the localhost redirect URI (no over-aggressive privacy/proxy tooling)"],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"5a9b9558db01a6b906cec2fb70a797affdc58cdd","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}