jdx/mise · error

Invalid platform format

Error message

Invalid platform format '{}'. Expected 'os-arch' or 'os-arch-qualifier'

What it means

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.

Solutions

  1. Write the full platform: "linux-x64", "macos-arm64", "windows-x86".
  2. Include a qualifier when needed: "linux-arm64-musl-baseline".
  3. Trim/verify the input string is non-empty and contains at least one hyphen before calling.

Example fix

// before
platform = "linux"
// after
platform = "linux-x64"
Defensive patterns

Strategy: validation

Validate before calling

// normalize and validate platform strings before passing to the API
function parsePlatformSafe(s) {
  const parts = String(s).trim().split("-");
  if (parts.length < 2) throw new Error(`Platform "${s}" must be os-arch or os-arch-qualifier`);
  return parts;
}

Type guard

function isPlatformString(v) {
  return typeof v === "string" && v.trim().split("-").length >= 2;
}

Try / catch

try {
  const p = Platform.parse(input);
} catch (e) {
  if (String(e).includes("Invalid platform format")) {
    throw new Error(`"${input}" is missing the architecture; e.g. use "linux-x64".`);
  } else throw e;
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

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 jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/a21e6800b5b3cd41. Report an issue: GitHub.

Appendix: source

Thrown at src/platform.rs:20

use eyre::{Result, bail};
use std::{collections::BTreeMap, fmt};

/// Represents a target platform for lockfile operations
#[derive(Debug, Clone, PartialEq, Eq, Hash, PartialOrd, Ord)]
pub(crate) struct Platform {
    pub os: String,
    pub arch: String,
    pub qualifier: Option<String>,
}

impl Platform {
    /// Parse a platform string in the format "os-arch" or "os-arch-qualifier"
    /// Qualifier may contain hyphens (e.g., "musl-baseline")
    pub(crate) fn parse(platform_str: &str) -> Result<Self> {
        let parts: Vec<&str> = platform_str.split('-').collect();

        match parts.len() {
            0 | 1 => bail!(
                "Invalid platform format '{}'. Expected 'os-arch' or 'os-arch-qualifier'",
                platform_str
            ),
            2 => Ok(Platform {
                os: parts[0].to_string(),
                arch: parts[1].to_string(),
                qualifier: None,
            }),
            _ => {
                // Join remaining parts as qualifier (handles compound qualifiers like "musl-baseline")
                let qualifier = parts[2..].join("-");
                Ok(Platform {
                    os: parts[0].to_string(),
                    arch: parts[1].to_string(),
                    qualifier: Some(qualifier),
                })
            }
        }

View on GitHub (pinned to 533346cc37)