zed-industries/zed · error
Failed to write credentials to Windows Credential Manager: {
Error message
Failed to write credentials to Windows Credential Manager: {} What it means
Raised in the spawned task of `write_credentials` when the `CredWriteW` call returns a non-zero Win32 error, so the generic credential (username/password for {url}) could not be persisted to Windows Credential Manager. Common underlying codes: ERROR_ACCESS_DENIED, ERROR_NO_SUCH_LOGON_SESSION, or the opaque 0x800706F7 stub error.
Source
Thrown at crates/gpui_windows/src/platform.rs:927
if password.len() > CRED_MAX_CREDENTIAL_BLOB_SIZE as usize {
return Task::ready(Err(anyhow!(
"credential for {url} is {} bytes, which exceeds the Windows Credential Manager limit of {CRED_MAX_CREDENTIAL_BLOB_SIZE} bytes",
password.len()
)));
}
let password = password.to_vec();
let mut username = username.encode_utf16().chain(Some(0)).collect_vec();
let mut target_name = windows_credentials_target_name(url)
.encode_utf16()
.chain(Some(0))
.collect_vec();
self.foreground_executor().spawn(async move {
let credentials = CREDENTIALW {
LastWritten: unsafe { GetSystemTimeAsFileTime() },
Flags: CRED_FLAGS(0),
Type: CRED_TYPE_GENERIC,
TargetName: PWSTR::from_raw(target_name.as_mut_ptr()),
CredentialBlobSize: password.len() as u32,
CredentialBlob: password.as_ptr() as *mut _,
Persist: CRED_PERSIST_LOCAL_MACHINE,
UserName: PWSTR::from_raw(username.as_mut_ptr()),
..CREDENTIALW::default()
};
unsafe {
CredWriteW(&credentials, 0).map_err(|err| {
anyhow!(
"Failed to write credentials to Windows Credential Manager: {}",
err,
)
})?;
}
Ok(())
})
}
fn read_credentials(&self, url: &str) -> Task<Result<Option<(String, Vec<u8>)>>> {View on GitHub (pinned to 9d272b0363)
Solutions
- Surface the formatted Win32 error (already via {}) to the caller/UI.
- Check the process has access to the user's logon session credential store.
- Verify CredentialBlobSize fits CRED_MAX_CREDENTIAL_BLOB_SIZE (guarded separately).
- Retry after logon session issues; ERROR_NO_SUCH_LOGON_SESSION can be transient in service contexts.
Defensive patterns
Strategy: try-catch
When it happens
Trigger: Thrown at crates/gpui_windows/src/platform.rs:862 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of zed-industries/zed@9d272b0363 (2026-08-20).
Data as JSON: /api/errors/922c1c3a8c937e80.
Report an issue: GitHub.