{"record":{"id":"a21e6800b5b3cd41","repo":"jdx/mise","slug":"invalid-platform-format-expected-os-arch-o","errorCode":null,"errorMessage":"Invalid platform format '{}'. Expected 'os-arch' or 'os-arch-qualifier'","messagePattern":"Invalid platform format '(.+?)'\\. Expected 'os-arch' or 'os-arch-qualifier'","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/platform.rs","lineNumber":20,"sourceCode":"use eyre::{Result, bail};\nuse std::{collections::BTreeMap, fmt};\n\n/// Represents a target platform for lockfile operations\n#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]\npub(crate) struct Platform {\n    pub os: String,\n    pub arch: String,\n    pub qualifier: Option<String>,\n}\n\nimpl Platform {\n    /// Parse a platform string in the format \"os-arch\" or \"os-arch-qualifier\"\n    /// Qualifier may contain hyphens (e.g., \"musl-baseline\")\n    pub(crate) fn parse(platform_str: &str) -> Result<Self> {\n        let parts: Vec<&str> = platform_str.split('-').collect();\n\n        match parts.len() {\n            0 | 1 => bail!(\n                \"Invalid platform format '{}'. Expected 'os-arch' or 'os-arch-qualifier'\",\n                platform_str\n            ),\n            2 => Ok(Platform {\n                os: parts[0].to_string(),\n                arch: parts[1].to_string(),\n                qualifier: None,\n            }),\n            _ => {\n                // Join remaining parts as qualifier (handles compound qualifiers like \"musl-baseline\")\n                let qualifier = parts[2..].join(\"-\");\n                Ok(Platform {\n                    os: parts[0].to_string(),\n                    arch: parts[1].to_string(),\n                    qualifier: Some(qualifier),\n                })\n            }\n        }","sourceCodeStart":2,"sourceCodeEnd":38,"githubUrl":"https://github.com/jdx/mise/blob/6f52dcdf99e282ef7a7db68c81301fa4618d0f79/src/platform.rs#L2-L38","documentation":"Platform strings must follow os-arch[-qualifier]; Platform::parse splits on '-' and bails when fewer than two parts exist — in practice, when the string contains no hyphen at all (split never yields zero parts; an empty string yields one). The string reaches parse via `mise lock -p/--platform` or the `lockfile_platforms` setting, both of which parse and then validate each entry.","triggerScenarios":"`mise lock -p linux`, `mise lock -p x64`, `lockfile_platforms = [\"linux\"]`, or an accidental \"\" entry in the settings list — any value lacking the os-arch hyphen structure.","commonSituations":"Assuming a bare OS or arch is sufficient; pasting Go/Rust target fragments like \"x86_64\" that are a single token; config edits leaving empty strings behind.","solutions":["Write the full os-arch pair: linux-x64, linux-arm64, macos-arm64, windows-x64.","Add a qualifier only when needed: linux-x64-musl or linux-x64-musl-baseline.","Check the effective list with `mise settings` to find the offending entry."],"exampleFix":"# before — mise.toml\n[settings]\nlockfile_platforms = [\"linux\", \"macos\"]\n\n# after\n[settings]\nlockfile_platforms = [\"linux-x64\", \"macos-arm64\"]","handlingStrategy":"validation","validationCode":"# Reject platform strings without the os-arch shape before invoking mise\nfor p in \"${PLATFORMS[@]}\"; do\n  [[ \"$p\" =~ ^[a-z0-9]+-[a-z0-9]+(-[a-z0-9-]+)?$ ]] || { echo \"bad platform: $p\"; exit 2; }\ndone\nmise lock -p \"${PLATFORMS[@]}\"","typeGuard":"fn has_os_arch_shape(s: &str) -> bool {\n    s.split('-').count() >= 2\n}","tryCatchPattern":null,"preventionTips":["Always specify the full os-arch pair; never a bare OS or arch.","Keep the platform list in one shared config snippet that CI validates.","Copy platform strings from mise's own defaults rather than composing them by hand."],"tags":["platform","validation","lockfile","config","mise-lock"],"backgroundTag":"invalid-platform-string","analyzedSha":"6f52dcdf99e282ef7a7db68c81301fa4618d0f79","analyzedAt":"2026-08-22T10:14:23.840Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}