{"record":{"id":"1c0be4964939c570","repo":"jdx/mise","slug":"history-origin-in-is-not-a-table","errorCode":null,"errorMessage":"[history.origin] in {} is not a table","messagePattern":"\\[history\\.origin\\] in (.+?) is not a table","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/system/history/sync/origin.rs","lineNumber":282,"sourceCode":"/// Writes the ordinary repository connection.\npub(super) fn write_config(url: &str, branch: &str, mode: Option<SyncMode>) -> Result<()> {\n    let global = origin_file()?;\n    if let Some(parent) = global.parent() {\n        crate::file::create_dir_all(parent)?;\n    }\n    let mut doc = crate::cli::dotfiles::track::read_document(&global)?;\n    let history = doc\n        .entry(\"history\")\n        .or_insert(Item::Table(toml_edit::Table::new()));\n    let Some(history) = history.as_table_mut() else {\n        bail!(\"[history] in {} is not a table\", display_path(&global));\n    };\n    history.set_implicit(true);\n    let origin = history\n        .entry(\"origin\")\n        .or_insert(Item::Table(toml_edit::Table::new()));\n    let Some(origin) = origin.as_table_mut() else {\n        bail!(\n            \"[history.origin] in {} is not a table\",\n            display_path(&global)\n        );\n    };\n    origin.set_implicit(false);\n    origin.insert(\"url\", Item::Value(Value::from(url)));\n    origin.insert(\"branch\", Item::Value(Value::from(branch)));\n    let Some(mode) = mode else {\n        crate::file::write(&global, doc.to_string())?;\n        return Ok(());\n    };\n    let settings = doc\n        .entry(\"settings\")\n        .or_insert(Item::Table(toml_edit::Table::new()));\n    let Some(settings) = settings.as_table_mut() else {\n        bail!(\"[settings] in {} is not a table\", display_path(&global));\n    };\n    settings.set_implicit(true);","sourceCodeStart":264,"sourceCodeEnd":300,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/system/history/sync/origin.rs#L264-L300","documentation":"Config-shape guard in origin write_config: the [history] table exists but its origin entry is not a table ([history.origin] is a scalar/array), so the writer cannot insert url/branch keys. It protects a malformed global config from being silently rewritten.","triggerScenarios":"Thrown at src/system/history/sync/origin.rs:282 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Edit the config so [history.origin] is a table with url and branch keys","Remove the malformed [history.origin] entry and re-run origin set","Validate the TOML structure of the global config file"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}