jdx/mise · error

Got non-HTML text from

Error message

Got non-HTML text from {}

What it means

get_html fetches a URL expecting an HTML document and validates the response's Content-Type. If the media type isn't text/html, it bails with 'Got non-HTML text from {url}' because the caller expected markup (usually for scraping docs/listings) and got JSON, plain text, or binary instead.

Solutions

  1. Confirm the URL returns HTML in a browser or `curl -I` (Content-Type should be text/html) and correct the URL if it points at an API or raw file.
  2. If the server sends a nonstandard Content-Type for HTML, fetch with get_text/get_async instead and parse manually.
  3. Check for redirects that land on a different content type; use the final canonical URL.
Defensive patterns

Strategy: validation

Validate before calling

ct=$(curl -fsSI "$url" | grep -i '^content-type:')
case "$ct" in *text/html*) echo ok ;; *) echo "non-HTML: $ct" ;; esac

Prevention

When it happens

Trigger: Calling get_html (src/http.rs:~790) on a URL whose server responds with a non-text/html Content-Type, e.g. an API endpoint returning application/json or a redirect landing on a raw file.

Common situations: Scraping a page whose URL now serves JSON (site/API change); hitting a mirror or CDN that returns a different content type; pointing an HTML scrape at an API endpoint by mistake.

Related errors


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

Appendix: source

Thrown at src/http.rs:804

        }
    }

    pub(crate) async fn get_html<U: IntoUrl>(&self, url: U) -> Result<String> {
        let url = url.into_url()?;
        let resp = self.get_async(url.clone()).await?;
        let is_html = resp
            .headers()
            .get(CONTENT_TYPE)
            .and_then(|content_type| content_type.to_str().ok())
            .is_some_and(|content_type| {
                content_type
                    .split_once(';')
                    .map_or(content_type, |(media_type, _)| media_type)
                    .trim()
                    .eq_ignore_ascii_case("text/html")
            });
        if !is_html {
            bail!("Got non-HTML text from {}", url);
        }
        let html = resp.text().await?;
        Ok(html)
    }

    pub(crate) async fn json_headers<T, U: IntoUrl>(&self, url: U) -> Result<(T, HeaderMap)>
    where
        T: serde::de::DeserializeOwned,
    {
        let url = url.into_url()?;
        let resp = self.get_async(url).await?;
        let headers = resp.headers().clone();
        let json = resp.json().await?;
        Ok((json, headers))
    }

    pub(crate) async fn json_headers_with_headers<T, U: IntoUrl>(
        &self,

View on GitHub (pinned to 533346cc37)