{"record":{"id":"80bf56f97be89a03","repo":"jdx/mise","slug":"repository-origin-must-not-contain-credentials-qu","errorCode":null,"errorMessage":"repository origin must not contain credentials, query parameters, or fragments","messagePattern":"repository origin must not contain credentials, query parameters, or fragments","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/remote_repository.rs","lineNumber":71,"sourceCode":"        && origin.split_once(\"::\").is_some_and(|(prefix, _)| {\n            !prefix.is_empty() && !prefix.contains(['/', '\\\\', '[', ']', '@', ':'])\n        })\n    {\n        bail!(\"Git remote helpers are not supported for remote onboarding\");\n    }\n    if !explicit_local && origin.contains(\"://\") {\n        let url = url::Url::parse(origin).wrap_err(\"invalid repository URL\")?;\n        if !matches!(url.scheme(), \"https\" | \"ssh\" | \"file\") {\n            bail!(\"remote bootstrap requires HTTPS, SSH, or a local path\");\n        }\n    }\n    if let Ok(url) = url::Url::parse(origin)\n        && (url.password().is_some()\n            || (url.scheme() != \"ssh\" && !url.username().is_empty())\n            || url.query().is_some()\n            || url.fragment().is_some())\n    {\n        bail!(\"repository origin must not contain credentials, query parameters, or fragments\");\n    }\n    Ok(())\n}\n\nimpl Source {\n    pub(crate) async fn fetch(origin: String) -> Result<Self> {\n        validate_origin(&origin)?;\n        let directory = tempfile::tempdir()?;\n        let repo = directory.path().join(\"repo\");\n        let mut command = Command::new(\"git\");\n        crate::git::sanitize_git_command(&mut command);\n        // No checkout: source templates and hooks are never evaluated locally.\n        command\n            .env(\"GIT_ALLOW_PROTOCOL\", \"https:ssh:file\")\n            .args([\"-c\", &crate::git::github_credential_config(\"github.com\")])\n            .args([\n                \"-c\",\n                &crate::git::github_credential_config(\"github.com:443\"),","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/remote_repository.rs#L53-L89","documentation":"validate_origin rejects repository URLs that embed credentials (username/password), query parameters, or fragments. Remote onboarding must be able to clone via local Git authentication, so tokens in the URL, `?ref=...` style queries, and `#fragments` are all refused.","triggerScenarios":"Calling Source::fetch or install_at with URLs like `https://user:token@host/repo.git`, `https://host/repo.git?ref=main`, or `https://host/repo.git#readme`, when the origin is not an explicitly local path. Note: for non-ssh schemes even a bare username triggers this.","commonSituations":"Pasting a PAT-bearing clone URL from a CI provider; appending `?ref=` to pin a branch (use the revision parameter instead); username in an https URL where only SSH URLs may carry one.","solutions":["Remove username/password from the URL and rely on configured Git credentials (credential helper, SSH key, netrc).","Remove query strings and fragments; pass the commit SHA via the revision parameter of install_at instead.","For ssh:// URLs keep the username if needed (ssh scheme allows usernames); for https use a bare URL.","Use an explicitly local path if you are working with a checked-out repository."],"exampleFix":"// before\ninstall_at(\"https://user:ghp_xxx@github.com/org/repo.git?ref=main\", rev, ...).await?;\n// after\ninstall_at(\"https://github.com/org/repo.git\", rev, ...).await?; // auth via git credential helper","handlingStrategy":"validation","validationCode":"function urlHasSecrets(origin: string): boolean {\n  try {\n    const u = new URL(origin);\n    return Boolean(u.password || (u.protocol !== \"ssh:\" && u.username) || u.search || u.hash);\n  } catch { return false; }\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never embed PATs in URLs; configure a git credential helper instead.","Strip ?query and #fragment before passing origins to mise.","Scan config files for `@` credentials in URLs in CI."],"tags":["git","url","security","credentials"],"backgroundTag":"invalid-url-format","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"}