jdx/mise · error

unsupported relay destination

Error message

unsupported relay destination

What it means

The relay's `request` method only proxies plain HTTPS GitHub URLs: https scheme, no username/password, and no explicit port are required. Any URL violating these constraints is rejected with "unsupported relay destination". This keeps the relay from being used as a generic proxy for arbitrary hosts or credentialed endpoints.

Solutions

  1. Normalize the URL: use https scheme, drop any :port, and remove userinfo from the URL.
  2. Pass credentials via headers (e.g. Authorization) rather than embedding user:password in the URL.
  3. Only request api.github.com or github.com paths through the relay; route other hosts directly.
  4. Remove any base-URL override env/config (e.g. GITHUB_API_URL style settings) that points at a non-standard endpoint.

Example fix

// before
let url = Url::parse("https://api.github.com:443/repos/foo/bar")?;
relay_request(&url).await?;
// after
let url = Url::parse("https://api.github.com/repos/foo/bar")?; // no port, no userinfo
relay_request(&url).await?;
Defensive patterns

Strategy: validation

Validate before calling

fn relay_destination_ok(url: &reqwest::Url) -> bool {
    url.scheme() == "https"
        && url.username().is_empty()
        && url.password().is_none()
        && url.port().is_none()
}

Try / catch

if !relay_destination_ok(&url) {
    return Err(anyhow!("URL must be https, credential-free, and portless for the relay"));
}

Prevention

When it happens

Trigger: Passing an http:// URL (not https) to the relay request path; a URL containing userinfo (user:pass@); a URL with an explicit port (e.g. https://api.github.com:443/); pointing the relay at a non-GitHub host is rejected separately as "unsupported relay host".

Common situations: Constructing API URLs with an explicit :443 port; embedding a token in the URL userinfo instead of headers; rewriting api.github.com to http in a dev/test environment; a config/env variable overriding the GitHub base URL to something the relay can't proxy.

Understand the failure class

Background: "Invalid URL" errors: why new URL(), URI.parse, and reqwest::Url reject your string — missing scheme, whitespace, and bad path format — this error's family across 39 libraries.

Related errors


AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/89f52fd6b012ba1d. Report an issue: GitHub.

Appendix: source

Thrown at src/github_relay.rs:990

            _ = hangup.recv() => Err(crate::request_exit(129)),
            result = operation => result,
        }
    }

    /// API adapter: an HTTP request over the forwarded private socket. No upstream
    /// authentication headers are sent to the target or supplied by the target.
    pub(crate) async fn request(
        socket: &Path,
        method: Method,
        url: &Url,
        headers: &http::HeaderMap,
    ) -> Result<reqwest::Response> {
        if url.scheme() != "https"
            || !url.username().is_empty()
            || url.password().is_some()
            || url.port().is_some()
        {
            bail!("unsupported relay destination");
        }
        let prefix = match url.host_str() {
            Some("api.github.com") => "api",
            Some("github.com") => "web",
            _ => bail!("unsupported relay host"),
        };
        let mut relay_url = Url::parse(&format!("http://localhost/{prefix}{}", url.path()))?;
        relay_url.set_query(url.query());
        let (client, request_timeout) = adapter_client(socket).await?;
        let mut req = client.request(method, relay_url);
        for name in ["accept", "range", "if-range"] {
            if let Some(value) = headers.get(name) {
                req = req.header(name, value);
            }
        }
        send_adapter_request(req, request_timeout).await
    }

View on GitHub (pinned to 533346cc37)