{"record":{"id":"cd7706c6d4277985","repo":"jdx/mise","slug":"scalar-values-were-converted-to-arrays","errorCode":null,"errorMessage":"scalar values were converted to arrays","messagePattern":"scalar values were converted to arrays","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/cli/config/set.rs","lineNumber":301,"sourceCode":"        let mut array = toml_edit::Array::new();\n        for value in additions {\n            array.push(value);\n        }\n        table.insert(key, toml_edit::value(array));\n        return Ok(());\n    };\n    if !existing.is_array() {\n        let original = existing\n            .as_value()\n            .cloned()\n            .ok_or_else(|| eyre::eyre!(\"cannot append to '{key}': value is not scalar or array\"))?;\n        let mut array = toml_edit::Array::new();\n        array.push(original);\n        *existing = toml_edit::value(array);\n    }\n    let array = existing\n        .as_array_mut()\n        .expect(\"scalar values were converted to arrays\");\n    for value in additions {\n        if !array.iter().any(|existing| values_equal(existing, &value)) {\n            array.push(value);\n        }\n    }\n    Ok(())\n}\n\nfn remove_value(\n    table: &mut dyn toml_edit::TableLike,\n    key: &str,\n    value: &toml_edit::Item,\n) -> eyre::Result<()> {\n    let removals = values(value.clone())?;\n    let Some(existing) = table.get_mut(key) else {\n        return Ok(());\n    };\n    if let Some(array) = existing.as_array_mut() {","sourceCodeStart":283,"sourceCodeEnd":319,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/cli/config/set.rs#L283-L319","documentation":"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]).","triggerScenarios":"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.","commonSituations":"Appending to a key whose existing value is an inline table like `{ cmd = \"...\" }`; scripted config edits where a key changed shape between runs.","solutions":["Do not append to table-valued keys; set the key to a plain value or array first","Manually edit mise.toml to make the target value an array or scalar before appending","Improve append_value to return a user-facing error for table values instead of panicking"],"exampleFix":"// before\nlet array = existing.as_array_mut().expect(\"scalar values were converted to arrays\");\n// after\nlet array = existing.as_array_mut().ok_or_else(|| anyhow!(\"cannot append to a table value; use set instead\"))?;","handlingStrategy":"validation","validationCode":"let existing = item.as_value(); if !(existing.is_array() || existing.is_scalar()) { return Err(anyhow!(\"cannot --append to a table value at '{key}'\")); }","typeGuard":"fn appendable(v: &toml_edit::Item) -> bool { v.is_array() || v.is_value() && !v.is_table_like() }","tryCatchPattern":"match existing.as_array_mut() { Some(a) => { /* append */ }, None => bail!(\"key holds a table; use set instead of append\"), }","preventionTips":["Inspect the current value with `mise config get <key>` before appending","Do not --append to keys defined as [tables] in mise.toml","Handle arrays vs tables distinctly in config-editing scripts"],"tags":["toml","config","cli","panic"],"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-14T00:17:10.932Z"}