From 04a2f059e28d4884f726768a386a8325325df192 Mon Sep 17 00:00:00 2001 From: Conrad Irwin Date: Mon, 23 Feb 2026 11:42:51 -0700 Subject: [PATCH] Don't panic in auth flow (#49916) Closes #49641 Before you mark this PR as ready for review, make sure that you have: - [ ] Added a solid test coverage and/or screenshots from doing manual testing - [ ] Done a self-review taking into account security and performance aspects - [ ] Aligned any UI changes with the [UI checklist](https://github.com/zed-industries/zed/blob/main/CONTRIBUTING.md#uiux-checklist) Release Notes: - Fixed panic when authentication failed to bind to lookback port --- crates/client/src/client.rs | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/crates/client/src/client.rs b/crates/client/src/client.rs index 48041f2271dadf2ebdd772a1a526421df05e063e..45bf43d4e73176dcfb16b14aa30cc4ce578b5b42 100644 --- a/crates/client/src/client.rs +++ b/crates/client/src/client.rs @@ -1369,9 +1369,9 @@ impl Client { // zed server to encrypt the user's access token, so that it can'be intercepted by // any other app running on the user's device. let (public_key, private_key) = - rpc::auth::keypair().expect("failed to generate keypair for auth"); + rpc::auth::keypair().context("failed to generate keypair for auth")?; let public_key_string = String::try_from(public_key) - .expect("failed to serialize public key for auth"); + .context("failed to serialize public key for auth")?; if let Some((login, token)) = IMPERSONATE_LOGIN.as_ref().zip(ADMIN_API_TOKEN.as_ref()) @@ -1386,8 +1386,8 @@ impl Client { } // Start an HTTP server to receive the redirect from Zed's sign-in page. - let server = - tiny_http::Server::http("127.0.0.1:0").expect("failed to find open port"); + let server = tiny_http::Server::http("127.0.0.1:0") + .map_err(|e| anyhow!(e).context("failed to bind callback port"))?; let port = server.server_addr().port(); // Open the Zed sign-in page in the user's browser, with query parameters that indicate