jdx/mise · error · eyre::Report

must not be empty

Error message

{field} must not be empty

What it means

This error comes from the `nonempty` helper in managed_files.rs, which validates optional string fields (e.g. owner, group, content identifiers) used when managing system files. If a caller supplies Some(value) whose trimmed content is empty (empty string or whitespace only), the library rejects it because an empty field is meaningless for file management operations. `None` is treated as 'not specified' and is accepted.

Solutions

  1. Remove the field entirely (or use null/None) instead of passing an empty string, so it is treated as unspecified
  2. Provide the actual intended value (user name, group name, etc.)
  3. Trim-check upstream: if the value comes from user input or env interpolation, reject or default empty input before calling the API

Example fix

// before
let opts = ManagedFileOptions { owner: Some("".to_string()), ..Default::default() };
// after
let opts = ManagedFileOptions { owner: Some("root".to_string()), ..Default::default() };
Defensive patterns

Strategy: validation

Validate before calling

fn ensure_nonempty(field: &str, value: &Option<String>) -> Result<(), String> {
    match value {
        Some(v) if v.trim().is_empty() => Err(format!("{field} must not be empty")),
        _ => Ok(()),
    }
}
ensure_nonempty("owner", &opts.owner)?;

Type guard

fn is_present_nonempty(v: &Option<String>) -> bool {
    v.as_deref().map_or(true, |s| !s.trim().is_empty())
}

Try / catch

match result {
    Err(e) if e.to_string().contains("must not be empty") => {
        // fall back to default / prompt user for a real value
    }
    other => other?,
}

Prevention

When it happens

Trigger: Calling any managed-files API that passes an optional string field through `nonempty` with Some("") or Some(" ") — e.g. setting an owner/group to an empty string, or parsing a manifest that declares a field with an empty value.

Common situations: Templated or generated config files where a variable expands to empty (unset env var interpolated into owner field); hand-edited manifests with `owner = ""`; YAML/TOML parsers deserializing blank values into Some("") instead of None.

Understand the failure class

Background: "must not be empty", "cannot be empty" — required-field validation errors across open-source libraries — this error's family across 41 libraries.

Related errors


AI-assisted analysis of jdx/mise@533346cc37 (2026-09-17). Data as JSON: /api/errors/e6a1cb75c78f9eef. Report an issue: GitHub.

Appendix: source

Thrown at src/system/managed_files.rs:1394

    }
    Ok(path)
}

fn parse_mode(mode: Option<&str>, default: u32) -> Result<u32> {
    let Some(mode) = mode else {
        return Ok(default);
    };
    let mode = mode.strip_prefix("0o").unwrap_or(mode);
    let parsed = u32::from_str_radix(mode, 8).wrap_err("mode must be an octal string")?;
    if parsed > 0o7777 {
        bail!("mode must be between 0000 and 7777");
    }
    Ok(parsed)
}

fn nonempty(field: &str, value: Option<String>) -> Result<Option<String>> {
    match value {
        Some(value) if value.trim().is_empty() => bail!("{field} must not be empty"),
        Some(value) => Ok(Some(value)),
        None => Ok(None),
    }
}

fn desired_metadata(kind: &str, mode: u32, owner: Option<&str>, group: Option<&str>) -> String {
    let mut desired = format!("{kind} mode {mode:04o}");
    if let Some(owner) = owner {
        desired.push_str(&format!(" owner {owner}"));
    }
    if let Some(group) = group {
        desired.push_str(&format!(" group {group}"));
    }
    desired
}

#[cfg(unix)]
fn metadata_matches(

View on GitHub (pinned to 533346cc37)