Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.
Reduce OAuth scope to avoid Windows credential size limit (#58541)
Artin5aa6e8a0b37a
diff --git a/crates/gpui_windows/src/platform.rs b/crates/gpui_windows/src/platform.rsindex 871da413e3b..9ba94563a40 100644--- a/crates/gpui_windows/src/platform.rs+++ b/crates/gpui_windows/src/platform.rs@@ -741,6 +741,15 @@ impl Platform for WindowsPlatform {}fn write_credentials(&self, url: &str, username: &str, password: &[u8]) -> Task<Result<()>> {+ // CredWriteW rejects larger blobs with the opaque RPC error+ // 0x800706F7 "The stub received bad data", so fail with a clear+ // message instead.+ 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)diff --git a/crates/language_models/src/provider/openai_subscribed.rs b/crates/language_models/src/provider/openai_subscribed.rsindex 20038e61234..e3ec95859a2 100644--- a/crates/language_models/src/provider/openai_subscribed.rs+++ b/crates/language_models/src/provider/openai_subscribed.rs@@ -760,10 +760,12 @@ async fn do_oauth_flow(.query_pairs_mut().append_pair("client_id", CLIENT_ID).append_pair("redirect_uri", &redirect_uri)- .append_pair(- "scope",- "openid profile email offline_access api.connectors.read api.connectors.invoke",- )+ // Deliberately excludes `api.connectors.read api.connectors.invoke`+ // (which Codex CLI requests): extra scopes inflate the+ // access-token JWT, and the serialized credentials must fit within+ // Windows Credential Manager's 2560-byte blob limit+ // (CRED_MAX_CREDENTIAL_BLOB_SIZE). See #58541.+ .append_pair("scope", "openid profile email offline_access").append_pair("response_type", "code").append_pair("code_challenge", &challenge).append_pair("code_challenge_method", "S256")