{"record":{"id":"fe271c9beec3e145","repo":"jdx/mise","slug":"collection-updates-require-scalar-or-array-values","errorCode":null,"errorMessage":"collection updates require scalar or array values","messagePattern":"collection updates require scalar or array values","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/config/set.rs","lineNumber":253,"sourceCode":"        } else {\n            table.insert(last_key, value);\n        }\n\n        let raw = config.to_string();\n        MiseToml::from_str(&raw, &file)?;\n        if let Some(parent) = file.parent() {\n            std::fs::create_dir_all(parent)?;\n        }\n        std::fs::write(&file, raw)?;\n        Ok(())\n    }\n}\n\nfn values(item: toml_edit::Item) -> eyre::Result<Vec<toml_edit::Value>> {\n    match item {\n        toml_edit::Item::Value(toml_edit::Value::Array(array)) => Ok(array.into_iter().collect()),\n        toml_edit::Item::Value(value) => Ok(vec![value]),\n        _ => bail!(\"collection updates require scalar or array values\"),\n    }\n}\n\nfn values_equal(left: &toml_edit::Value, right: &toml_edit::Value) -> bool {\n    if let (Some(left), Some(right)) = (left.as_str(), right.as_str()) {\n        return left == right;\n    }\n    if let (Some(left), Some(right)) = (left.as_integer(), right.as_integer()) {\n        return left == right;\n    }\n    if let (Some(left), Some(right)) = (left.as_float(), right.as_float()) {\n        return left == right;\n    }\n    if let (Some(left), Some(right)) = (left.as_bool(), right.as_bool()) {\n        return left == right;\n    }\n    if let (Some(left), Some(right)) = (left.as_datetime(), right.as_datetime()) {\n        return left == right;","sourceCodeStart":235,"sourceCodeEnd":271,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/cli/config/set.rs#L235-L271","documentation":"The `values` helper in `mise config set` converts an existing TOML item into a list of values for append/remove operations. It only supports an existing TOML array (returns its elements) or a single scalar value (wraps it in a one-element vec). If the targeted key holds a table (or is otherwise not a value), there is no sensible element list, so it bails with 'collection updates require scalar or array values'.","triggerScenarios":"Calling `mise config set --append` or `--remove` on a key that currently resolves to a TOML table (nested config section) or to a non-value item (e.g. missing/none), via append_value or remove_value.","commonSituations":"Trying to append to a key that is actually a subsection like `[env]` or `[settings.something]` with children, or a typo in the key path that lands on a table instead of the intended scalar/array.","solutions":["Target the specific scalar or array key inside the table instead of the table itself (e.g. `env.MY_LIST` not `env`)","Verify the current value with `mise config get <key>` to confirm it is a scalar or array before appending/removing","Create the key as an array first (via `mise config set` with an array type) if it does not exist yet"],"exampleFix":"// before\nmise config set --append env.list 3   # env is a table -> error\n// after\nmise config set --append env.MY_LIST 3","handlingStrategy":"validation","validationCode":"val=$(mise config get \"$KEY\")\nif [[ \"$val\" == *'{'* ]]; then echo \"$KEY is a table; target a scalar/array child\"; exit 1; fi","typeGuard":null,"tryCatchPattern":"if let Err(e) = result {\n    if e.to_string().contains(\"collection updates require scalar or array values\") {\n        // target a child key or create the key as an array first\n    }\n}","preventionTips":["Run `mise config get <key>` before append/remove to confirm the value shape","Do not target table/section names with --append/--remove","Keep list values as TOML arrays in your config so collection ops work"],"tags":["cli","config","toml"],"backgroundTag":"incompatible-source-type","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}