jdx/mise · error

GitHub API URL should be valid

Error message

GitHub API URL should be valid

What it means

This panic fires when `Url::parse(github::API_URL)` fails while building the GitHub API URL for a repo tarball lookup in the aqua backend. `github::API_URL` is a compile-time constant well-formed URL, so the parse only fails if that constant is corrupted or a non-canonical override was introduced. It is an internal invariant check, not a condition users can normally reach.

Source

Thrown at src/backend/aqua.rs:2302

                asset_strs.iter().join(", "),
                gh_release.assets.iter().map(|a| &a.name).join("\n")
            )
        })?;

        Ok((
            asset.browser_download_url.to_string(),
            Some(asset.url.to_string()),
            asset.digest.clone(),
        ))
    }

    fn github_archive_url(&self, pkg: &AquaPackage, v: &str) -> String {
        let gh_id = format!("{}/{}", pkg.repo_owner, pkg.repo_name);
        format!("https://github.com/{gh_id}/archive/refs/tags/{v}.tar.gz")
    }

    fn github_archive_api_url(&self, pkg: &AquaPackage, v: &str) -> String {
        let mut url = Url::parse(github::API_URL).expect("GitHub API URL should be valid");
        url.path_segments_mut()
            .expect("GitHub API URL should support path segments")
            .extend([
                "repos",
                pkg.repo_owner.as_str(),
                pkg.repo_name.as_str(),
                "tarball",
                v,
            ]);
        url.to_string()
    }

    fn github_content_url(&self, pkg: &AquaPackage, v: &str) -> String {
        let gh_id = format!("{}/{}", pkg.repo_owner, pkg.repo_name);
        let path = pkg.path.as_deref().unwrap();
        format!("https://raw.githubusercontent.com/{gh_id}/{v}/{path}")
    }

View on GitHub (pinned to afd2eddd3a)

Solutions

  1. Verify `github::API_URL` in src/backend/github.rs is a well-formed absolute URL like "https://api.github.com/"
  2. If overriding for GitHub Enterprise/testing, ensure the override is a full valid URL including scheme and trailing slash
  3. Update mise to the latest version; report a bug with the backtrace if it reproduces on an unmodified build

Example fix

// before
let mut url = Url::parse(github::API_URL).expect("GitHub API URL should be valid");
// after
let mut url = Url::parse(github::API_URL)
    .unwrap_or_else(|e| panic!("github::API_URL {:?} is not a valid URL: {e}", github::API_URL));
Defensive patterns

Strategy: validation

Validate before calling

let parsed = url::Url::parse(github::API_URL);
assert!(parsed.is_ok(), "github::API_URL must be a valid absolute URL: {:?}", parsed.err());

Type guard

fn is_valid_url(s: &str) -> bool { url::Url::parse(s).map(|u| u.has_host()).unwrap_or(false) }

Try / catch

let url = match url::Url::parse(github::API_URL) { Ok(u) => u, Err(e) => { eprintln!("bad API_URL: {e}"); return; } };

Prevention

When it happens

Trigger: Calling `github_archive_api_url` (aqua release asset resolution for github_release packages) when `github::API_URL` no longer parses as a valid absolute URL — realistically only after a code change or bad patch of the constant.

Common situations: Practically unreachable in production; seen only during development/refactoring of the github backend base URL (e.g. GitHub Enterprise URL experiments) or when mocking `github::API_URL` in tests with a malformed value.

Understand the failure class

Background: "This is a bug, please report it": internal invariant violations, unreachable panics, and SNH errors explained — this error's family across 47 libraries.

Related errors


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