gitbutlerapp/gitbutler · error

Invalid version format

Error message

Invalid version format: {version}. Version must contain at least one alphanumeric character.

What it means

After the character whitelist passes, validate requires at least one alphanumeric character so pure punctuation strings like `...`, `---`, or `+` are rejected. The message echoes the input and explains the requirement.

Solutions

  1. Provide a real version containing digits or letters, e.g. `0.14.2`.
  2. Check that any glob/variable feeding the argument actually expanded (add `set -u`/`shopt -s failglob`).
  3. Validate the value in CI before invoking: `[[ $V =~ [A-Za-z0-9] ]] || exit 1`.
  4. Use `nightly` as a safe default when no concrete version is known.

Example fix

// before
but-installer ...
// after
but-installer 0.14.2
Defensive patterns

Strategy: validation

Validate before calling

assert!(version.chars().any(|c| c.is_alphanumeric()), "version needs at least one letter or digit: got '{version}'");

Try / catch

match InstallerConfig::new() {
    Err(e) if e.to_string().contains("at least one alphanumeric") => {
        eprintln!("{e}");
        std::process::exit(2);
    }
    Err(e) => return Err(e),
    Ok(cfg) => run(cfg),
}

Prevention

When it happens

Trigger: Passing a version consisting only of separators/dots, e.g. `but-installer ...` from a glob expansion that failed, `but-installer --` (caught earlier), or a variable expanded to `.`/`..`/`-` by a misconfigured script.

Common situations: Shell scripts where a glob like `v*.*` did not match and stayed literal; tab-completion inserting `..`; templated CI configs where the substitution evaluated to a placeholder of dots.

Understand the failure class

Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/0f929d430efff9da. Report an issue: GitHub.

Appendix: source

Thrown at crates/but-installer/src/config.rs:67

        // Reject if it looks like a flag
        if version.starts_with('-') {
            bail!("Invalid version: {version}. Usage: but-installer [version|nightly]");
        }

        // Only allow semver-compatible characters
        if !version
            .chars()
            .all(|c| c.is_alphanumeric() || c == '.' || c == '-' || c == '+')
        {
            bail!(
                "Invalid version format: {version}. Version must contain only alphanumeric characters, dots, hyphens, and plus signs."
            );
        }

        // Must contain at least one alphanumeric character
        if !version.chars().any(|c| c.is_alphanumeric()) {
            bail!(
                "Invalid version format: {version}. Version must contain at least one alphanumeric character."
            );
        }

        Ok(())
    }

    /// Get the version string as a &str
    pub fn as_str(&self) -> &str {
        &self.0
    }
}

impl AsRef<str> for Version {
    fn as_ref(&self) -> &str {
        &self.0
    }
}

View on GitHub (pinned to 58e5313667)