xai-org/grok-build · error

invalid version format: '{}'

Error message

invalid version format: '{}'

What it means

download_verified_from_base accepts an explicit target version; if one is supplied it must parse as valid semver. This error is thrown when the requested version string fails semver::Version::parse. It exists to reject malformed version pins before any download is attempted.

Source

Thrown at crates/codegen/xai-grok-update/src/auto_update.rs:1635

    binary_path: std::path::PathBuf,
}

/// Base-dependent install phase: resolve the version (per base when no
/// target is pinned), download the binary, and smoke-test it. Network /
/// fetch failures here are worth retrying against another base URL.
/// [`SmokeTestFailure`] is not — see [`install_internal_from_bases`].
async fn download_verified_from_base(
    target: Option<&str>,
    update_config: &UpdateConfig,
    gcs_base_url: &str,
) -> Result<VerifiedDownload> {
    let (os, arch) = detect_platform()?;
    let platform = format!("{}-{}", os, arch);

    let version = match target {
        Some(v) => {
            semver::Version::parse(v)
                .map_err(|_| anyhow::anyhow!("invalid version format: '{}'", v))?;
            v.to_string()
        }
        None => {
            crate::version::fetch_gcs_version_from_base(&update_config.channel, gcs_base_url)
                .await?
        }
    };

    let grok_home = grok_home();
    let download_dir = grok_home.join("downloads");
    tokio::fs::create_dir_all(&download_dir).await?;

    let binary_name = format!("grok-{}-{}", version, platform);
    let binary_path = download_dir.join(&binary_name);

    eprintln!("  Downloading grok v{} ({})...", version, platform);

    // Published already +x (see `publish_downloaded_artifact`).

View on GitHub (pinned to bc7f02eddd)

Solutions

  1. Pass a plain semver string without the leading 'v' (e.g. "1.2.3" not "v1.2.3")
  2. Omit target (pass None) to let the updater fetch the latest version from the channel pointer
  3. Verify the string parses with semver (major.minor.patch, optional pre-release/build)

Example fix

// before
install_internal_from_base(Some("v2.1.0"), &cfg).await?;
// after
install_internal_from_base(Some("2.1.0"), &cfg).await?;
// or fetch latest automatically:
install_internal_from_base(None, &cfg).await?;
Defensive patterns

Strategy: validation

Validate before calling

fn is_valid_semver(v: &str) -> bool { semver::Version::parse(v).is_ok() }
// call before: if !is_valid_semver(target) { bail!(...) }

Type guard

fn is_semver_version(v: &str) -> bool {
    semver::Version::parse(v).is_ok()
}

Try / catch

match install_internal_from_base(Some(target), &cfg).await {
    Err(e) if e.to_string().starts_with("invalid version format") => {
        eprintln!("pass plain semver like 1.2.3 (no leading 'v'), or None for latest");
    }
    result => result?,
}

Prevention

When it happens

Trigger: Calling install_internal_from_bases / install_internal_from_base with target set to a non-semver string such as "v1.2.3", "1.2", "latest", "main", or a version with invalid characters.

Common situations: Users typing "grok update v1.2.3" or "grok update latest"; scripts piping branch names or tags with a leading 'v'; copy-pasted versions with whitespace or build metadata typos.

Related errors


AI-assisted analysis of xai-org/grok-build@bc7f02eddd (2026-08-31). Data as JSON: /api/errors/9ab0f705cc79b3a8. Report an issue: GitHub.