{"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":347,"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":329,"sourceCodeEnd":365,"githubUrl":"https://github.com/jdx/mise/blob/533346cc374382b41ec5ff70536252b2e96e725c/src/system/history/sync/origin.rs#L329-L365","documentation":"Within `[history]`, `write_config` needs a `[history.origin]` sub-table to store the sync origin URL and mode. If `history.origin` exists but holds a non-table value, mise bails instead of clobbering it.","triggerScenarios":"set_inner -> write_config: after inserting `[history]`, the existing `origin` entry inside it is not a table, so `as_table_mut()` returns None.","commonSituations":"Hand-edited config with `origin = \"git@...\"` (scalar) under `[history]` instead of `[history.origin]`; a settings-style `history.origin` string value written by an older version or another tool.","solutions":["Edit the global config so origin is a sub-table: `[history.origin]` with `url = \"...\"`, or delete the `origin` key and retry","Remove the scalar `origin` key under `[history]` and re-run `mise dot origin set`","Validate the global config's TOML structure before re-running"],"exampleFix":"// before\n[history]\norigin = \"git@github.com:user/repo.git\"\n// after\n[history.origin]\nurl = \"git@github.com:user/repo.git\"","handlingStrategy":"validation","validationCode":"// verify [history.origin] is a table before connecting\nlet doc = global.parse::<toml::Table>()?;\nif let Some(o) = doc.get(\"history\").and_then(|h| h.get(\"origin\")) && !o.is_table() {\n    eprintln!(\"fix [history.origin] in the global config: it must be a table\");\n}","typeGuard":null,"tryCatchPattern":"match result {\n    Err(e) if e.to_string().contains(\"[history.origin] is not a table\") => {\n        eprintln!(\"rewrite history.origin as a [history.origin] table, then retry\");\n    }\n    _ => {}\n}","preventionTips":["Never write history.origin as a string; always use [history.origin] with url/mode keys","Let `mise dot origin set` manage the section instead of hand-editing","Re-validate the global config after merging changes from other tools"],"tags":["toml","config","schema"],"backgroundTag":"config-type-mismatch","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}