jdx/mise · error

scalar values were converted to arrays

Error message

scalar values were converted to arrays

What it means

A `.expect()` panic in `mise config set` append handling (src/cli/config/set.rs:301, `append_value`). The code first converts a scalar existing value into a one-element array; the expect asserts the value is now an array. It panics when the existing TOML value is neither scalar nor array — typically a table (inline table or [section]).

Source

Thrown at src/cli/config/set.rs:301

        let mut array = toml_edit::Array::new();
        for value in additions {
            array.push(value);
        }
        table.insert(key, toml_edit::value(array));
        return Ok(());
    };
    if !existing.is_array() {
        let original = existing
            .as_value()
            .cloned()
            .ok_or_else(|| eyre::eyre!("cannot append to '{key}': value is not scalar or array"))?;
        let mut array = toml_edit::Array::new();
        array.push(original);
        *existing = toml_edit::value(array);
    }
    let array = existing
        .as_array_mut()
        .expect("scalar values were converted to arrays");
    for value in additions {
        if !array.iter().any(|existing| values_equal(existing, &value)) {
            array.push(value);
        }
    }
    Ok(())
}

fn remove_value(
    table: &mut dyn toml_edit::TableLike,
    key: &str,
    value: &toml_edit::Item,
) -> eyre::Result<()> {
    let removals = values(value.clone())?;
    let Some(existing) = table.get_mut(key) else {
        return Ok(());
    };
    if let Some(array) = existing.as_array_mut() {

View on GitHub (pinned to afd2eddd3a)

Solutions

  1. Do not append to table-valued keys; set the key to a plain value or array first
  2. Manually edit mise.toml to make the target value an array or scalar before appending
  3. Improve append_value to return a user-facing error for table values instead of panicking

Example fix

// before
let array = existing.as_array_mut().expect("scalar values were converted to arrays");
// after
let array = existing.as_array_mut().ok_or_else(|| anyhow!("cannot append to a table value; use set instead"))?;
Defensive patterns

Strategy: validation

Validate before calling

let existing = item.as_value(); if !(existing.is_array() || existing.is_scalar()) { return Err(anyhow!("cannot --append to a table value at '{key}'")); }

Type guard

fn appendable(v: &toml_edit::Item) -> bool { v.is_array() || v.is_value() && !v.is_table_like() }

Try / catch

match existing.as_array_mut() { Some(a) => { /* append */ }, None => bail!("key holds a table; use set instead of append"), }

Prevention

When it happens

Trigger: Running `mise config set --append key value` (append path) where `key` currently holds a TOML table, e.g. `mise config set --append tasks.build ...` when `tasks.build` is a `[tasks.build]` table in mise.toml.

Common situations: Appending to a key whose existing value is an inline table like `{ cmd = "..." }`; scripted config edits where a key changed shape between runs.

Related errors


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