{"record":{"id":"44347dec3996dbc2","repo":"jdx/mise","slug":"unsupported-relay-host","errorCode":null,"errorMessage":"unsupported relay host","messagePattern":"unsupported relay host","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/github_relay.rs","lineNumber":995,"sourceCode":"    /// API adapter: an HTTP request over the forwarded private socket. No upstream\n    /// authentication headers are sent to the target or supplied by the target.\n    pub(crate) async fn request(\n        socket: &Path,\n        method: Method,\n        url: &Url,\n        headers: &http::HeaderMap,\n    ) -> Result<reqwest::Response> {\n        if url.scheme() != \"https\"\n            || !url.username().is_empty()\n            || url.password().is_some()\n            || url.port().is_some()\n        {\n            bail!(\"unsupported relay destination\");\n        }\n        let prefix = match url.host_str() {\n            Some(\"api.github.com\") => \"api\",\n            Some(\"github.com\") => \"web\",\n            _ => bail!(\"unsupported relay host\"),\n        };\n        let mut relay_url = Url::parse(&format!(\"http://localhost/{prefix}{}\", url.path()))?;\n        relay_url.set_query(url.query());\n        let (client, request_timeout) = adapter_client(socket).await?;\n        let mut req = client.request(method, relay_url);\n        for name in [\"accept\", \"range\", \"if-range\"] {\n            if let Some(value) = headers.get(name) {\n                req = req.header(name, value);\n            }\n        }\n        send_adapter_request(req, request_timeout).await\n    }\n\n    // Obtain the initiating machine's policy, not the target's saved settings.\n    // Discovery itself has a short fixed bound and bypasses broker request slots.\n    async fn adapter_client(socket: &Path) -> Result<(Client, Duration)> {\n        let builder = || {\n            Client::builder()","sourceCodeStart":977,"sourceCodeEnd":1013,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/github_relay.rs#L977-L1013","documentation":"After validating scheme/credentials/port, `request` maps the URL host to a relay prefix: api.github.com -> \"api\", github.com -> \"web\". Any other host cannot be proxied and produces \"unsupported relay host\". The relay is intentionally restricted to GitHub API and web endpoints.","triggerScenarios":"Requesting a URL whose host is not exactly api.github.com or github.com (case/whitespace aside), e.g. objects.githubusercontent.com, gist.github.com, an enterprise GitHub host (github.example.com), or raw.githubusercontent.com through the relay request path.","commonSituations":"Following a redirect or API-provided URL (e.g. raw.githubusercontent.com) back through the relay; GitHub Enterprise Server users pointing tooling at their own host; typos like api.github.com.evil.com or api,ggithub.com.","solutions":["Use only api.github.com or github.com URLs with this relay path.","For other hosts (raw/objects CDN, enterprise), fetch directly with a normal HTTP client instead of the relay.","Fix base-URL configuration that substitutes an enterprise or mirror host for GitHub.","If you're hitting a suspicious host, check DNS/hosts-file tampering — the exact-host match may be protecting you."],"exampleFix":"// before\nlet url = Url::parse(\"https://raw.githubusercontent.com/foo/bar/main/README.md\")?;\nrelay_request(&url).await?; // bails: unsupported relay host\n// after\nlet resp = reqwest::get(url).await?; // fetch non-GitHub hosts directly","handlingStrategy":"validation","validationCode":"fn relay_host_ok(url: &reqwest::Url) -> bool {\n    matches!(url.host_str(), Some(\"api.github.com\") | Some(\"github.com\"))\n}","typeGuard":null,"tryCatchPattern":"if relay_host_ok(&url) { relay_request(&url).await } else { reqwest::get(url).await.map_err(Into::into) }","preventionTips":["Only route api.github.com/github.com through the relay; fetch raw/CDN hosts directly","Never substitute enterprise or mirror hosts into relay URLs","Treat an 'unsupported relay host' on a github.com-looking URL as a possible DNS tampering signal"],"tags":["http","url","github","allowlist","proxy"],"backgroundTag":"unsupported-operation","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}