zed-industries/zed · error

failed to set URL scheme

Error message

failed to set URL scheme

What it means

Returned when url.set_scheme (mapping https→wss, http→ws) rejects the target scheme. The URL type only permits certain scheme transitions, so this fires when the built Zed Cloud URL cannot be converted to a WebSocket URL — a defensive guard around an unexpected URL state rather than a user input error.

Solutions

  1. Check that the Zed Cloud URL is well-formed and its scheme mapping is supported
  2. Report as a bug if it reproduces with a standard https Zed Cloud URL, since the https→wss transition should always succeed
Defensive patterns

Strategy: fallback

When it happens

Trigger: Thrown at crates/cloud_api_client/src/websocket/web.rs:65 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of zed-industries/zed@f4178619ac (2026-08-20). Data as JSON: /api/errors/3dd5c704f5a2cc52. Report an issue: GitHub.

Appendix: source

Thrown at crates/cloud_api_client/src/websocket/web.rs:65

        (message_rx.into_stream().boxed(), task)
    }
}

impl CloudApiClient {
    pub fn connect(self: &std::sync::Arc<Self>, cx: &App) -> Result<Task<Result<Connection>>> {
        let client = self.clone();
        let executor = cx.background_executor().clone();
        Ok(cx.spawn(async move |_cx| {
            let mut connect_url = client
                .http_client
                .build_zed_cloud_url("/client/users/connect")?;
            connect_url
                .set_scheme(match connect_url.scheme() {
                    "https" => "wss",
                    "http" => "ws",
                    scheme => return Err(anyhow!("invalid URL scheme: {scheme}")),
                })
                .map_err(|_| anyhow!("failed to set URL scheme"))?;


            let connect = WebSocket::connect(connect_url).fuse();
            let timeout = executor.timer(CONNECT_TIMEOUT).fuse();
            futures::pin_mut!(connect, timeout);
            let websocket = futures::select_biased! {
                result = connect => result.map_err(|error| anyhow!("failed to connect to Cloud WebSocket: {error}"))?,
                _ = timeout => return Err(anyhow!("timed out connecting to Cloud WebSocket")),
            };

            Ok(Connection::new(websocket))
        }))
    }
}

View on GitHub (pinned to f4178619ac)