{"record":{"id":"15c3fd1dd7425dc5","repo":"jdx/mise","slug":"expected-value-of-to-be-a-got","errorCode":null,"errorMessage":"expected value of {} to be a {}, got: {}","messagePattern":"expected value of (.+?) to be a (.+?), got: (.+?)","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/toml.rs","lineNumber":8,"sourceCode":"use std::collections::HashSet;\n\n#[macro_export]\nmacro_rules! parse_error {\n    ($key:expr, $val:expr, $t:expr) => {{\n        use eyre::bail;\n\n        bail!(\n            r#\"expected value of {} to be a {}, got: {}\"#,\n            $crate::ui::style::eyellow($key),\n            $crate::ui::style::ecyan($t),\n            $crate::ui::style::eblue($val.to_string().trim()),\n        )\n    }};\n}\n\npub(crate) fn dedup_toml_array(array: &toml_edit::Array) -> toml_edit::Array {\n    let mut seen = HashSet::new();\n    let mut deduped = toml_edit::Array::new();\n    for item in array.iter() {\n        if seen.insert(item.as_str()) {\n            deduped.push(item.clone());\n        }\n    }\n    deduped\n}","sourceCodeStart":1,"sourceCodeEnd":26,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/toml.rs#L1-L26","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Read the error's key and expected type, then fix the mise.toml value at that path to the expected type","Compare against documented mise.toml schema (mise.jdx.dev/configuration) for the offending key","Validate the file with `mise doctor` or the JSON schema to catch structural mistakes"],"exampleFix":"# before\n[tools]\nnode = \"22\"\n\n# after (tools must map to version tables/strings per schema; a bare scalar under [tools] as a table is wrong)\n[tools]\nnode = \"22\"  # ensure nesting like [tools.node] if a table value is required","handlingStrategy":"validation","validationCode":"# validate mise.toml structure before use\nimport tomllib\ncfg = tomllib.load(open('mise.toml','rb'))\nassert isinstance(cfg.get('tools', {}), dict), '[tools] must be a table'\nfor k, v in cfg['tools'].items():\n    assert isinstance(v, (str, dict)), f'tools.{k} must be a string or table'","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate mise.toml against the published JSON schema in your editor","Run `mise doctor` after config edits","Don't mix .tool-versions syntax into mise.toml tables"],"tags":["toml","config","type-mismatch","parsing"],"backgroundTag":"config-type-mismatch","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}