{"record":{"id":"9ab0f705cc79b3a8","repo":"xai-org/grok-build","slug":"invalid-version-format","errorCode":null,"errorMessage":"invalid version format: '{}'","messagePattern":"invalid version format: '(.+?)'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/codegen/xai-grok-update/src/auto_update.rs","lineNumber":1635,"sourceCode":"    binary_path: std::path::PathBuf,\n}\n\n/// Base-dependent install phase: resolve the version (per base when no\n/// target is pinned), download the binary, and smoke-test it. Network /\n/// fetch failures here are worth retrying against another base URL.\n/// [`SmokeTestFailure`] is not — see [`install_internal_from_bases`].\nasync fn download_verified_from_base(\n    target: Option<&str>,\n    update_config: &UpdateConfig,\n    gcs_base_url: &str,\n) -> Result<VerifiedDownload> {\n    let (os, arch) = detect_platform()?;\n    let platform = format!(\"{}-{}\", os, arch);\n\n    let version = match target {\n        Some(v) => {\n            semver::Version::parse(v)\n                .map_err(|_| anyhow::anyhow!(\"invalid version format: '{}'\", v))?;\n            v.to_string()\n        }\n        None => {\n            crate::version::fetch_gcs_version_from_base(&update_config.channel, gcs_base_url)\n                .await?\n        }\n    };\n\n    let grok_home = grok_home();\n    let download_dir = grok_home.join(\"downloads\");\n    tokio::fs::create_dir_all(&download_dir).await?;\n\n    let binary_name = format!(\"grok-{}-{}\", version, platform);\n    let binary_path = download_dir.join(&binary_name);\n\n    eprintln!(\"  Downloading grok v{} ({})...\", version, platform);\n\n    // Published already +x (see `publish_downloaded_artifact`).","sourceCodeStart":1617,"sourceCodeEnd":1653,"githubUrl":"https://github.com/xai-org/grok-build/blob/bc7f02eddd3d84085849dc19ed216f11c23b0571/crates/codegen/xai-grok-update/src/auto_update.rs#L1617-L1653","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Pass a plain semver string without the leading 'v' (e.g. \"1.2.3\" not \"v1.2.3\")","Omit target (pass None) to let the updater fetch the latest version from the channel pointer","Verify the string parses with semver (major.minor.patch, optional pre-release/build)"],"exampleFix":"// before\ninstall_internal_from_base(Some(\"v2.1.0\"), &cfg).await?;\n// after\ninstall_internal_from_base(Some(\"2.1.0\"), &cfg).await?;\n// or fetch latest automatically:\ninstall_internal_from_base(None, &cfg).await?;","handlingStrategy":"validation","validationCode":"fn is_valid_semver(v: &str) -> bool { semver::Version::parse(v).is_ok() }\n// call before: if !is_valid_semver(target) { bail!(...) }","typeGuard":"fn is_semver_version(v: &str) -> bool {\n    semver::Version::parse(v).is_ok()\n}","tryCatchPattern":"match install_internal_from_base(Some(target), &cfg).await {\n    Err(e) if e.to_string().starts_with(\"invalid version format\") => {\n        eprintln!(\"pass plain semver like 1.2.3 (no leading 'v'), or None for latest\");\n    }\n    result => result?,\n}","preventionTips":["Strip a leading 'v' from user-supplied versions before calling","Validate with semver::Version::parse before pinning a version","Pass None to fetch the channel's latest instead of guessing a string","Trim whitespace from CLI/script inputs"],"tags":["validation","semver","version"],"backgroundTag":"invalid-version-format","analyzedSha":"bc7f02eddd3d84085849dc19ed216f11c23b0571","analyzedAt":"2026-08-31T04:59:42.031Z","schemaVersion":2},"datasetVersion":"2026-08-31T09:17:48.483Z"}