{"record":{"id":"b967a6f2ee766922","repo":"Hmbown/CodeWhale","slug":"segment-in-config-toml-must-be-a-table","errorCode":null,"errorMessage":"`{segment}` in config.toml must be a table","messagePattern":"`(.+?)` in config\\.toml must be a table","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/config/src/config_document.rs","lineNumber":449,"sourceCode":"    let mut current: &mut dyn toml_edit::TableLike = root;\n    for segment in segments {\n        if current.get(segment).is_none() {\n            match lookup {\n                PathLookup::Create => {\n                    let mut table = toml_edit::Table::new();\n                    table.set_implicit(true);\n                    current.insert(segment, toml_edit::Item::Table(table));\n                }\n                PathLookup::Existing => return Ok(None),\n            }\n        }\n        let item = current\n            .get_mut(segment)\n            .expect(\"segment exists or was inserted above\");\n        match item.as_table_like_mut() {\n            Some(table) => current = table,\n            None => match lookup {\n                PathLookup::Create => bail!(\"`{segment}` in config.toml must be a table\"),\n                PathLookup::Existing => return Ok(None),\n            },\n        }\n    }\n    Ok(Some(current))\n}\n\n#[cfg(test)]\nmod tests {\n    #[test]\n    fn healing_keeps_a_non_table_extras_key_it_cannot_lift() {\n        // `extras` is where the config structs flatten unknown keys, so a\n        // scalar or array under that exact name round-trips through the typed\n        // path as ordinary user data. Healing used to `remove()` it before\n        // discovering it was not a table, dropping it on the very next\n        // `codewhale config set` — and reporting `healed == false` while doing\n        // so.\n        for body in [","sourceCodeStart":431,"sourceCodeEnd":467,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/config/src/config_document.rs#L431-L467","documentation":"Thrown by table_like_at_path_mut when walking a dotted path inside config.toml: an intermediate segment resolves to a non-table value (e.g. a string or integer), but the operation needs a table to descend into or create. For Create lookups the library refuses to overwrite the existing scalar; for Existing lookups it reports the path as absent (Ok(None)) via the caller. It protects the TOML document from being silently reshaped.","triggerScenarios":"set_config_document_value with a path like \"provider.name\" where `provider` is currently a string/number/bool in config.toml; unset_config_document_value walking through the same conflict; editing config.toml by hand so a key that used to be a section [provider] becomes a scalar `provider = \"x\"`.","commonSituations":"Merging snippets into config.toml where a section header is accidentally converted to a key-value pair; older config versions with flat keys being addressed with nested paths.","solutions":["Open config.toml and convert the offending key into a section: change `provider = \"x\"` to `[provider]` with the child keys under it","Use a path whose intermediate segments are actual TOML tables","Remove the scalar key if it is obsolete, then set the nested value","Back up and regenerate the config section with the tooling's default writer"],"exampleFix":"// before (config.toml)\nmodel = \"glm\"\nmodel.temperature = 0.5\n// after (config.toml)\n[model]\nname = \"glm\"\ntemperature = 0.5","handlingStrategy":"validation","validationCode":"// Check each intermediate segment is a TOML table before setting\nfn segments_ok(doc: &toml::Value, path: &str) -> bool {\n    let segs: Vec<&str> = path.split('.').collect();\n    for s in &segs[..segs.len()-1] {\n        match doc.get(*s) {\n            Some(v) if v.is_table() => {}\n            _ => return false,\n        }\n    }\n    true\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Never convert a [section] header into a scalar key when hand-editing config.toml","Validate the TOML document shape after merges or migrations","Keep nested paths in sync with the document's actual structure"],"tags":["toml","config","type-mismatch"],"backgroundTag":"config-type-mismatch","analyzedSha":"73e0f67d83c59909b571efdfc88c4bc28c309cb1","analyzedAt":"2026-09-22T01:30:00.501Z","contentChangedAt":"2026-09-22T01:30:00.501Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}