Hmbown/CodeWhale · error
segment exists or was inserted above
Error message
segment exists or was inserted above
What it means
Invariant inside table_like_at_path_mut(): when descending a segment it either finds an existing table-like item or just inserted one; unwrap of the newly inserted entry can only fail if insertion silently failed, which indicates a toml_edit API misuse or code bug rather than user error.
Source
Thrown at crates/config/src/config_document.rs:433
root: &'a mut toml_edit::Table,
segments: &[&str],
lookup: PathLookup,
) -> Result<Option<&'a mut dyn toml_edit::TableLike>> {
let mut current: &mut dyn toml_edit::TableLike = root;
for segment in segments {
if current.get(segment).is_none() {
match lookup {
PathLookup::Create => {
let mut table = toml_edit::Table::new();
table.set_implicit(true);
current.insert(segment, toml_edit::Item::Table(table));
}
PathLookup::Existing => return Ok(None),
}
}
let item = current
.get_mut(segment)
.expect("segment exists or was inserted above");
match item.as_table_like_mut() {
Some(table) => current = table,
None => match lookup {
PathLookup::Create => bail!("`{segment}` in config.toml must be a table"),
PathLookup::Existing => return Ok(None),
},
}
}
Ok(Some(current))
}
#[cfg(test)]
mod tests {
#[test]
fn healing_lifts_nested_extras_towers_to_the_top_level() {
let tmp = tempfile::tempdir().expect("tempdir");
let path = tmp.path().join("config.toml");
std::fs::write(View on GitHub (pinned to 0c42157ee5)
Solutions
- Inspect how the segment was inserted/mutated and fix the insertion path
- Report a bug with the config path segments that triggered it
Defensive patterns
Strategy: type-guard
When it happens
Trigger: Thrown at crates/config/src/config_document.rs:433 when the library encounters an invalid state.
Common situations: See trigger scenarios.
AI-assisted analysis of Hmbown/CodeWhale@0c42157ee5 (2026-08-20).
Data as JSON: /api/errors/afa9848cc0be914c.
Report an issue: GitHub.