From b9af6645e3824a6bc94a5c2b051fb857c104bbe8 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Wed, 26 Nov 2025 13:01:01 +0100 Subject: [PATCH] gpui: Return `None` for non-existing credentials in `read_credentials` on windows (#43540) Release Notes: - N/A *or* Added/Fixed/Improved ... --- crates/gpui/src/platform/windows/platform.rs | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/crates/gpui/src/platform/windows/platform.rs b/crates/gpui/src/platform/windows/platform.rs index 006099c3828efb11b0981e81635fba0c452c8560..942cb62d2216c8d7cd5ea4cf75c4e4fa4a7d007f 100644 --- a/crates/gpui/src/platform/windows/platform.rs +++ b/crates/gpui/src/platform/windows/platform.rs @@ -642,15 +642,24 @@ impl Platform for WindowsPlatform { .collect_vec(); self.foreground_executor().spawn(async move { let mut credentials: *mut CREDENTIALW = std::ptr::null_mut(); - unsafe { + let result = unsafe { CredReadW( PCWSTR::from_raw(target_name.as_ptr()), CRED_TYPE_GENERIC, None, &mut credentials, - )? + ) }; + if let Err(err) = result { + // ERROR_NOT_FOUND means the credential doesn't exist. + // Return Ok(None) to match macOS and Linux behavior. + if err.code().0 == ERROR_NOT_FOUND.0 as i32 { + return Ok(None); + } + return Err(err.into()); + } + if credentials.is_null() { Ok(None) } else {