{"record":{"id":"a2d8af989e386eeb","repo":"Hmbown/CodeWhale","slug":"create-lookups-always-yield-a-table","errorCode":null,"errorMessage":"Create lookups always yield a table","messagePattern":"Create lookups always yield a table","errorType":"panic","errorClass":null,"httpStatus":null,"severity":"error","filePath":"crates/config/src/config_document.rs","lineNumber":131,"sourceCode":"                crate::quote_os_path(path)\n            );\n        }\n        persist_locked(path, current.as_deref(), body.as_bytes())\n    })\n}\n\n/// Set a value at `segments`, creating implicit parent tables while preserving\n/// existing key/value decor.\npub fn set_config_document_value(\n    doc: &mut toml_edit::DocumentMut,\n    segments: &[&str],\n    value: impl Into<toml_edit::Value>,\n) -> Result<()> {\n    let (key, parents) = segments\n        .split_last()\n        .context(\"config value path must not be empty\")?;\n    let table = table_like_at_path_mut(doc.as_table_mut(), parents, PathLookup::Create)?\n        .expect(\"Create lookups always yield a table\");\n    match table.get_mut(key) {\n        Some(item) => {\n            let mut value = value.into();\n            if let Some(existing) = item.as_value() {\n                *value.decor_mut() = existing.decor().clone();\n            }\n            *item = toml_edit::Item::Value(value);\n        }\n        None => {\n            table.insert(key, toml_edit::value(value));\n        }\n    }\n    Ok(())\n}\n\n/// Remove a value at `segments` without disturbing unrelated tables or decor.\npub fn unset_config_document_value(\n    doc: &mut toml_edit::DocumentMut,","sourceCodeStart":113,"sourceCodeEnd":149,"githubUrl":"https://github.com/Hmbown/CodeWhale/blob/73e0f67d83c59909b571efdfc88c4bc28c309cb1/crates/config/src/config_document.rs#L113-L149","documentation":"set_config_document_value splits the key path into parents + final key, asks table_like_at_path_mut for PathLookup::Create, and expects a table back. The Create lookup is contractually guaranteed to build and return a table, so a None would mean an internal bug in table_like_at_path_mut; this expect documents and enforces that invariant.","triggerScenarios":"Only reachable if table_like_at_path_mut(doc.as_table_mut(), parents, PathLookup::Create) returns Ok(None) — a violation of its Create contract while setting a config value via targeted mutations (provider edits, lock revoke/update tests).","commonSituations":"A code change to table_like_at_path_mut breaking the Create contract; never from user input — end users cannot trigger it through the public config-store API.","solutions":["Debug table_like_at_path_mut: under PathLookup::Create it must insert and return a table for each missing segment.","Add/repair the unit test covering Create on a missing intermediate segment.","Report as a bug — this is an internal invariant, not an input error."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"// unreachable from user input; treat any panic here as a bug report\nstd::panic::catch_unwind(|| store.set(&path, value))","preventionTips":["Keep unit tests covering PathLookup::Create on missing intermediate tables.","Never bypass the shared document lock when mutating the config.","Review changes to table_like_at_path_mut against its Create contract."],"tags":["internal","config","invariant"],"backgroundTag":"internal-invariant-violation","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"}