From f722e2fb2f71864a98ebde9a1cea0fbda6934221 Mon Sep 17 00:00:00 2001 From: Hamza Paracha <86984199+DevDonzo@users.noreply.github.com> Date: Thu, 16 Apr 2026 00:06:21 -0400 Subject: [PATCH] Respect proxy settings when fetching JSON schemas (#53954) This fixes #53819. JSON schema downloads were still going through the JSON language server without picking up Zed's configured proxy. On networks that require the proxy, that made schema fetches fail even though the rest of the app could connect normally. This passes the proxy setting through to the JSON language server configuration so schema requests follow the same network path as the rest of Zed. ## Test plan - `rustfmt --edition 2024 crates/languages/src/json.rs` - `git diff --check -- crates/languages/src/json.rs` Release Notes: - Fixed JSON schema downloads ignoring Zed's proxy setting. --------- Co-authored-by: Christopher Biscardi --- crates/languages/src/json.rs | 41 ++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) diff --git a/crates/languages/src/json.rs b/crates/languages/src/json.rs index de30d958d006016a118f2db077e38c1212f4f683..b1bcd0043e520730631b30818e0e504a50b0e84e 100644 --- a/crates/languages/src/json.rs +++ b/crates/languages/src/json.rs @@ -296,6 +296,13 @@ impl LspAdapter for JsonLspAdapter { } }) }); + + if let Some(proxy_settings) = cx.update(|cx| { + json_schema_proxy_settings(cx.http_client().proxy().map(ToString::to_string)) + }) { + merge_json_value_into(proxy_settings, &mut config); + } + let project_options = cx.update(|cx| { language_server_settings(delegate.as_ref(), &self.name(), cx) .and_then(|s| worktree_root(delegate, s.settings.clone())) @@ -356,6 +363,16 @@ fn worktree_root(delegate: &Arc, settings: Option Some(Value::Object(settings_map)) } +fn json_schema_proxy_settings(proxy: Option) -> Option { + proxy.map(|proxy| { + json!({ + "http": { + "proxy": proxy, + } + }) + }) +} + async fn get_cached_server_binary( container_dir: PathBuf, node: &NodeRuntime, @@ -376,6 +393,30 @@ async fn get_cached_server_binary( .log_err() } +#[cfg(test)] +mod tests { + use serde_json::json; + + use super::json_schema_proxy_settings; + + #[test] + fn test_json_schema_proxy_settings_includes_proxy() { + assert_eq!( + json_schema_proxy_settings(Some("http://proxy.example:8080".to_string())), + Some(json!({ + "http": { + "proxy": "http://proxy.example:8080", + } + })) + ); + } + + #[test] + fn test_json_schema_proxy_settings_ignores_missing_proxy() { + assert_eq!(json_schema_proxy_settings(None), None); + } +} + pub struct NodeVersionAdapter; impl NodeVersionAdapter {