jdx/mise · error

expected value of {} to be a {}, got: {}

Error message

expected value of {} to be a {}, got: {}

What it means

The parse_error! macro is mise's standard helper for type mismatches when parsing TOML config: a value found at a key is not the expected type (e.g. a string where a table was expected). It formats a styled message showing the key, expected type, and the offending value.

Source

Thrown at src/toml.rs:8

use std::collections::HashSet;

#[macro_export]
macro_rules! parse_error {
    ($key:expr, $val:expr, $t:expr) => {{
        use eyre::bail;

        bail!(
            r#"expected value of {} to be a {}, got: {}"#,
            $crate::ui::style::eyellow($key),
            $crate::ui::style::ecyan($t),
            $crate::ui::style::eblue($val.to_string().trim()),
        )
    }};
}

pub(crate) fn dedup_toml_array(array: &toml_edit::Array) -> toml_edit::Array {
    let mut seen = HashSet::new();
    let mut deduped = toml_edit::Array::new();
    for item in array.iter() {
        if seen.insert(item.as_str()) {
            deduped.push(item.clone());
        }
    }
    deduped
}

View on GitHub (pinned to afd2eddd3a)

Solutions

  1. Read the error's key and expected type, then fix the mise.toml value at that path to the expected type
  2. Compare against documented mise.toml schema (mise.jdx.dev/configuration) for the offending key
  3. Validate the file with `mise doctor` or the JSON schema to catch structural mistakes

Example fix

# before
[tools]
node = "22"

# after (tools must map to version tables/strings per schema; a bare scalar under [tools] as a table is wrong)
[tools]
node = "22"  # ensure nesting like [tools.node] if a table value is required
Defensive patterns

Strategy: validation

Validate before calling

# validate mise.toml structure before use
import tomllib
cfg = tomllib.load(open('mise.toml','rb'))
assert isinstance(cfg.get('tools', {}), dict), '[tools] must be a table'
for k, v in cfg['tools'].items():
    assert isinstance(v, (str, dict)), f'tools.{k} must be a string or table'

Prevention

When it happens

Trigger: Any call site expanding parse_error!(key, val, type) — i.e. deserializing mise.toml/.mise.toml/config values where, say, `[tools]` contains a scalar instead of a table, or an env var entry is a table where a string was expected.

Common situations: Typos in mise.toml structure (tools entry written as string not table); mixing .tool-versions style values into mise.toml; wrong nesting of env or task tables after edits.

Related errors


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