{"record":{"id":"922c1c3a8c937e80","repo":"zed-industries/zed","slug":"failed-to-write-credentials-to-windows-credential","errorCode":null,"errorMessage":"Failed to write credentials to Windows Credential Manager: {}","messagePattern":"Failed to write credentials to Windows Credential Manager: (.+?)","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/gpui_windows/src/platform.rs","lineNumber":927,"sourceCode":"        if password.len() > CRED_MAX_CREDENTIAL_BLOB_SIZE as usize {\n            return Task::ready(Err(anyhow!(\n                \"credential for {url} is {} bytes, which exceeds the Windows Credential Manager limit of {CRED_MAX_CREDENTIAL_BLOB_SIZE} bytes\",\n                password.len()\n            )));\n        }\n        let password = password.to_vec();\n        let mut username = username.encode_utf16().chain(Some(0)).collect_vec();\n        let mut target_name = windows_credentials_target_name(url)\n            .encode_utf16()\n            .chain(Some(0))\n            .collect_vec();\n        self.foreground_executor().spawn(async move {\n            let credentials = CREDENTIALW {\n                LastWritten: unsafe { GetSystemTimeAsFileTime() },\n                Flags: CRED_FLAGS(0),\n                Type: CRED_TYPE_GENERIC,\n                TargetName: PWSTR::from_raw(target_name.as_mut_ptr()),\n                CredentialBlobSize: password.len() as u32,\n                CredentialBlob: password.as_ptr() as *mut _,\n                Persist: CRED_PERSIST_LOCAL_MACHINE,\n                UserName: PWSTR::from_raw(username.as_mut_ptr()),\n                ..CREDENTIALW::default()\n            };\n            unsafe {\n                CredWriteW(&credentials, 0).map_err(|err| {\n                    anyhow!(\n                        \"Failed to write credentials to Windows Credential Manager: {}\",\n                        err,\n                    )\n                })?;\n            }\n            Ok(())\n        })\n    }\n\n    fn read_credentials(&self, url: &str) -> Task<Result<Option<(String, Vec<u8>)>>> {","sourceCodeStart":909,"sourceCodeEnd":945,"githubUrl":"https://github.com/zed-industries/zed/blob/9d272b036335401f339d024ea94968fd51016c40/crates/gpui_windows/src/platform.rs#L909-L945","documentation":"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.","triggerScenarios":"Thrown at crates/gpui_windows/src/platform.rs:862 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","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."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"9d272b036335401f339d024ea94968fd51016c40","analyzedAt":"2026-08-20T19:29:52.058Z","contentChangedAt":"2026-08-20T19:29:52.058Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}