jdx/mise · error

too many redirects

Error message

too many redirects

What it means

After following the allowed number of redirects while proxying a GitHub download, the relay checks the final response: if it is still a 3xx redirection, it stops and bails with "too many redirects". This guards against redirect loops from GitHub or an intercepting middlebox.

Solutions

  1. Retry the download — transient CDN redirect loops often resolve.
  2. Inspect the redirect chain with `curl -sIL <asset-url>` to identify the loop or offending host; fix proxy/DNS if a middlebox is rewriting Location.
  3. Update mise to pick up current redirect allowlist/limits if GitHub changed its download endpoints.
  4. Download the artifact directly (outside the relay) if your network environment keeps looping through the proxy.
Defensive patterns

Strategy: retry

Try / catch

for attempt in 0..3 {
    match relay_download(url).await {
        Err(e) if e.to_string().contains("too many redirects") && attempt < 2 => continue,
        other => break other,
    }
}

Prevention

When it happens

Trigger: The asset/archive download chain returns more redirects than the relay's loop bound allows (the `loop { ... }` in `forward` exhausts its iterations and the last response status is_redirection); or a redirect cycle (A -> B -> A) exists in the chain.

Common situations: GitHub or the CDN issues a redirect loop; a corporate proxy rewrites Location headers producing a cycle; a stale/changed GitHub download host keeps 302-ing; rate-limit or auth middleware bouncing between endpoints.

Understand the failure class

Background: 'Something went wrong' / 'Request failed (500)' / 'HTTP error! status: 404' — what failed HTTP requests actually mean and how to find the real cause — this error's family across 28 libraries.

Related errors


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

Appendix: source

Thrown at src/github_relay.rs:685

                || !(asset_redirect(&url) || archive_redirect(&url, target.archive_repo.as_deref()))
            {
                bail!("unsupported redirect");
            }
            let redirect_host = url.host_str().unwrap_or_default().to_string();
            let redirected_at = std::time::Instant::now();
            let mut redirected = broker.client.request(parts.method.clone(), url);
            for name in ["range", "if-range"] {
                if let Some(value) = parts.headers.get(name) {
                    redirected = redirected.header(name, value);
                }
            }
            response = redirected.send().await?;
            if broker.audit.options.log_requests {
                broker.audit.emit(serde_json::json!({"event": "request", "operation": format!("{} {redirect_host}/<download>", parts.method), "status": response.status().as_u16(), "headers_ms": redirected_at.elapsed().as_millis()}));
            }
        }
        if response.status().is_redirection() {
            bail!("too many redirects");
        }
        let mut builder = Response::builder().status(response.status());
        for name in [
            "content-type",
            "content-length",
            "content-range",
            "etag",
            "last-modified",
            "link",
            // Rate-limit metadata. GitHub reports an exhausted limit as 403,
            // so without these the caller cannot tell one from a refusal and
            // retries nothing — see `is_github_rate_limited`. They describe
            // the broker's own budget, which is what a caller needs in order
            // to back off, and carry no credential.
            "retry-after",
            "x-ratelimit-limit",
            "x-ratelimit-remaining",
            "x-ratelimit-reset",

View on GitHub (pinned to 533346cc37)