jdx/mise · error

`ref` must not start with `-`

Error message

`ref` must not start with `-`

What it means

Injection-safety validation in system repos from_toml(): the repo config's `ref` field starts with '-' after trimming, which a git command line could interpret as an option flag. The bail rejects ref values that could become argument injection.

Source

Thrown at src/system/repos.rs:135

                if let Component::Normal(segment) = component {
                    resolved.push(segment);
                }
            }
            resolved
        };
        let Some(url) = config.url.map(|s| s.trim().to_string()) else {
            bail!("must set `url`");
        };
        if url.is_empty() {
            bail!("must set a non-empty `url`");
        }
        if url.starts_with('-') {
            bail!("`url` must not start with `-`");
        }
        let git_ref = config.git_ref.map(|s| s.trim().to_string());
        let git_ref = match git_ref {
            Some(git_ref) if git_ref.is_empty() => bail!("`ref` must not be empty"),
            Some(git_ref) if git_ref.starts_with('-') => bail!("`ref` must not start with `-`"),
            other => other,
        };
        Ok(Self {
            path_raw,
            path,
            url,
            git_ref,
        })
    }
}

impl std::fmt::Display for RepoRequest {
    fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
        write!(f, "{}", file::display_path(&self.path))
    }
}

pub(crate) async fn status(requests: &[RepoRequest]) -> Result<Vec<RepoStatus>> {

View on GitHub (pinned to afd2eddd3a)

Solutions

  1. Use only a branch name, tag, or SHA for `ref` (optionally prefixed with an explicit `refs/heads/`, `refs/tags/`, or SHA form).
  2. Remove any git flags from the ref value.
  3. Audit the config file for misplaced fields.

Example fix

// before
[[repos]]
path = "repo"
url = "https://github.com/org/repo.git"
ref = "--track"

// after
[[repos]]
path = "repo"
url = "https://github.com/org/repo.git"
ref = "main"
Defensive patterns

Strategy: validation

Validate before calling

fn is_safe_ref(r: &str) -> bool {
    let r = r.trim();
    !r.is_empty() && !r.starts_with('-')
}

Prevention

When it happens

Trigger: Calling from_toml with `git_ref = "--force"` or any hyphen-leading value.

Common situations: Pasting git options into the ref field; shifted/generated config fields; malicious repo configs.

Understand the failure class

Background: "Must be a positive integer", "Invalid value", "Unsupported": the invalid-argument-value error family, when a library rejects the value you pass — this error's family across 35 libraries.

Related errors


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