{"record":{"id":"0a87e05249ea0e08","repo":"GitoxideLabs/gitoxide","slug":"undo-metadata-contains-an-unknown-section","errorCode":null,"errorMessage":"undo metadata contains an unknown section","messagePattern":"undo metadata contains an unknown section","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-tix/src/edit/undo.rs","lineNumber":612,"sourceCode":"\nfn parse_config(repo: &gix::Repository, body: &BStr) -> Result<Vec<RefChange>> {\n    let config = File::try_from(body).context(\"could not parse undo metadata as Git config\")?;\n    let mut sections = config.sections();\n    let undo = sections.next().context(\"undo metadata has no version section\")?;\n    ensure!(\n        undo.header().name() == b\"undo\" && undo.header().subsection_name().is_none(),\n        \"undo metadata must start with [undo]\"\n    );\n    ensure_exact_keys(&undo, &[\"version\"])?;\n    ensure!(\n        undo.value(\"version\").as_ref().map(|value| value.as_slice()) == Some(VERSION.as_bytes()),\n        \"unsupported undo metadata version\"\n    );\n\n    let mut changes = Vec::new();\n    let mut previous_name: Option<FullName> = None;\n    for section in sections {\n        ensure!(\n            section.header().name() == b\"ref\",\n            \"undo metadata contains an unknown section\"\n        );\n        let subsection = section\n            .header()\n            .subsection_name()\n            .context(\"an undo ref section has no reference name\")?;\n        let name = FullName::try_from(subsection).context(\"an undo entry contains an invalid reference name\")?;\n        ensure!(!is_queue_ref(name.as_bstr()), \"the undo queue records itself\");\n        if let Some(previous) = &previous_name {\n            ensure!(\n                previous < &name,\n                \"undo reference sections are duplicated or out of order\"\n            );\n        }\n        previous_name = Some(name.clone());\n        ensure_exact_keys(&section, &[\"before\", \"after\"])?;\n        let before = section.value(\"before\").context(\"an undo ref has no before-state\")?;","sourceCodeStart":594,"sourceCodeEnd":630,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-tix/src/edit/undo.rs#L594-L630","documentation":"When tix restores or inspects undo state, it parses the stored undo metadata as a Git config file. After the leading `[undo]` version section, every remaining section must be a `[ref \"<name>\"]` section describing one reference change. This error is raised when any subsequent section has a header name other than `ref`, meaning the metadata file was hand-edited, corrupted, or written by an incompatible version of tix.","triggerScenarios":"Calling any undo/redo flow that reaches `parse_config` (via `parse_commit`) while the stored undo metadata body contains a section like `[other]` or `[refextra \"...\"]` after the `[undo]` header — typically from manual editing of the metadata ref, a merge conflict inside it, or tampering.","commonSituations":"A developer edits the undo metadata ref (or a merge leaves conflict markers in it), an old tix version wrote a different section layout, or an external tool rewrote the refs storage.","solutions":["Inspect the undo metadata and remove or fix any section whose header is not `[ref \"<reference-name>\"]`","Regenerate the undo metadata by re-running the operation that produced it, or clear the undo state and redo the ref changes manually","Check for merge-conflict markers in the metadata if it was touched by a merge","Ensure all tix versions used against the repository are from the same compatible release"],"exampleFix":"// before (corrupt metadata body)\n[undo]\n\tversion = v1\n[ref \"refs/heads/main\"]\n\tbefore = missing\n\tafter = object:abc123\n[stale]\n\tkey = value\n// after\n[undo]\n\tversion = v1\n[ref \"refs/heads/main\"]\n\tbefore = missing\n\tafter = object:abc123","handlingStrategy":"validation","validationCode":"// before reading undo state, validate the metadata body\nlet config = gix::config::File::try_from(body.as_ref())?;\nlet mut sections = config.sections();\nlet undo = sections.next().ok_or(\"missing [undo] header\")?;\nassert_eq!(undo.header().name(), b\"undo\");\nfor s in sections {\n    assert_eq!(s.header().name(), b\"ref\", \"unknown section {:?}\", s.header().name());\n}","typeGuard":"fn is_ref_section(header: &gix::config::file::Header<'_>) -> bool {\n    header.name() == b\"ref\" && header.subsection_name().is_some()\n}","tryCatchPattern":"match load_undo_state(&repo) {\n    Ok(changes) => apply(changes),\n    Err(e) if e.to_string().contains(\"unknown section\") => {\n        eprintln!(\"undo metadata corrupt; resetting undo state\");\n        reset_undo_state(&repo)?;\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Never hand-edit the undo metadata ref; use tix commands","Check for merge-conflict markers if the metadata ref was touched by a merge","Keep all tix installations on a compatible version","Validate the metadata body after any external tool touches refs"],"tags":["git","config","validation","undo"],"backgroundTag":"schema-validation-failed","analyzedSha":"e73179060badf27222d790981fac3f84c1830a7e","analyzedAt":"2026-09-08T11:26:50.865Z","contentChangedAt":"2026-09-08T11:26:50.865Z","schemaVersion":2},"datasetVersion":"2026-09-15T23:17:13.987Z"}