{"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/533346cc374382b41ec5ff70536252b2e96e725c/src/platform.rs#L2-L38","documentation":"Raised by Platform::parse when a platform string cannot be split into at least an os-arch pair. The accepted formats are \"os-arch\" (2 hyphen-separated parts) or \"os-arch-qualifier\" (3+ parts, where the qualifier may itself contain hyphens, e.g. \"musl-baseline\"). Anything with 0 or 1 hyphen-separated parts is invalid.","triggerScenarios":"Calling Platform::parse with a string like \"linux\" or \"\" — split('-') yields 0 or 1 parts — typically from user-supplied platform settings or CLI arguments for packslip/aqua tool selection.","commonSituations":"Passing just an OS name (\"linux\") without an architecture; an empty or whitespace-only platform string; accidentally swapping the argument order so a non-platform string is parsed.","solutions":["Write the full platform: \"linux-x64\", \"macos-arm64\", \"windows-x86\".","Include a qualifier when needed: \"linux-arm64-musl-baseline\".","Trim/verify the input string is non-empty and contains at least one hyphen before calling."],"exampleFix":"// before\nplatform = \"linux\"\n// after\nplatform = \"linux-x64\"","handlingStrategy":"validation","validationCode":"// normalize and validate platform strings before passing to the API\nfunction parsePlatformSafe(s) {\n  const parts = String(s).trim().split(\"-\");\n  if (parts.length < 2) throw new Error(`Platform \"${s}\" must be os-arch or os-arch-qualifier`);\n  return parts;\n}","typeGuard":"function isPlatformString(v) {\n  return typeof v === \"string\" && v.trim().split(\"-\").length >= 2;\n}","tryCatchPattern":"try {\n  const p = Platform.parse(input);\n} catch (e) {\n  if (String(e).includes(\"Invalid platform format\")) {\n    throw new Error(`\"${input}\" is missing the architecture; e.g. use \"linux-x64\".`);\n  } else throw e;\n}","preventionTips":["Always specify both OS and architecture: \"os-arch\" at minimum.","Keep a lookup table of valid platform strings for your tools and validate input against it in CI.","Trim user input and reject empty strings early."],"tags":["platform","parsing","configuration","format"],"backgroundTag":"invalid-argument-format","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}