jdx/mise · error

setup repository URLs must not contain credentials, query…

Error message

setup repository URLs must not contain credentials, query parameters, or fragments; use a Git credential helper or SSH agent

What it means

validate_url refuses repository URLs that contain a username/password, query string, or fragment. Credentials in persisted URLs leak into config, logs, and the history-health error records; query/fragment parts have no meaning for git remotes and usually indicate a malformed or hostile URL. The error directs users to git credential helpers or the SSH agent.

Solutions

  1. Remove the username:password portion from the URL and configure a git credential helper (git credential-store, helper, or manager) instead
  2. Remove any ?query or #fragment from the URL
  3. For token auth over HTTPS, use the credential helper or switch to an SSH remote with your agent

Example fix

# before
remote = "https://ci:ghp_xxx@github.com/org/repo.git?ref=main"
# after
remote = "https://github.com/org/repo.git"
# plus: git config --global credential.helper manager (or store token out of band)
Defensive patterns

Strategy: validation

Validate before calling

const u = new URL(url);
if (u.username || u.password || u.search || u.hash) {
  throw new Error("remote URL must not contain credentials, query, or fragment");
}

Type guard

function isCredentialFreeUrl(v: string): boolean {
  try {
    const u = new URL(v);
    return !u.username && !u.password && !u.search && !u.hash;
  } catch { return false; }
}

Try / catch

match validate_url(&value) {
    Err(e) if e.to_string().contains("must not contain credentials") => {
        eprintln!("{e}; move the token into a credential helper");
        return Err(e);
    }
    other => other?,
}

Prevention

When it happens

Trigger: validate_url (via fetch_with_depth, push, symbolic_head, ls_remote) receiving a parsed http(s) URL with a password set, or an http(s) URL with a nonempty username, query, or fragment — e.g. "https://user:token@host/repo.git?ref=main#frag".

Common situations: Pasting an access-token URL copied from a web UI (https://x-access-token:TOKEN@github.com/...); putting ?private_token= on a GitLab URL; a tracking/UTM fragment left in a copied URL.

Related errors


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

Appendix: source

Thrown at src/system/history/sync/network.rs:44

        .trim_start()
        .get(..5)
        .is_some_and(|prefix| prefix.eq_ignore_ascii_case("http:"))
        || value
            .trim_start()
            .get(..6)
            .is_some_and(|prefix| prefix.eq_ignore_ascii_case("https:"));
    if http_like && url::Url::parse(value).is_err() {
        bail!("invalid HTTP setup repository URL; use a Git credential helper for authentication");
    }
    if let Ok(url) = url::Url::parse(value) {
        let http = matches!(url.scheme(), "http" | "https");
        if url.password().is_some()
            || (http
                && (!url.username().is_empty()
                    || url.query().is_some()
                    || url.fragment().is_some()))
        {
            bail!(
                "setup repository URLs must not contain credentials, query parameters, or fragments; use a Git credential helper or SSH agent"
            );
        }
    }
    Ok(())
}

#[cfg(test)]
mod tests {
    use super::{HistoryRepo, PushOutcome, Remote, UPSTREAM_REF, validate_url};

    #[test]
    fn disposable_tip_probe_is_shallow_but_ordinary_fetch_keeps_ancestry() {
        let temp = tempfile::tempdir().unwrap();
        let source = HistoryRepo::open_or_init_in(&temp.path().join("source"))
            .unwrap()
            .unwrap();
        let tree = source.empty_object("tree").unwrap();

View on GitHub (pinned to 533346cc37)