{"record":{"id":"67111b15d6c84131","repo":"GitoxideLabs/gitoxide","slug":"the-rebase-state-contains-duplicate-scope-commits","errorCode":null,"errorMessage":"the rebase state contains duplicate scope commits","messagePattern":"the rebase state contains duplicate scope commits","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-tix/src/edit/todo.rs","lineNumber":782,"sourceCode":"        head_ref,\n        edit_refs,\n        expected_refs,\n        resolved,\n        continuation_sources,\n    };\n    validate_state(repo, &state)?;\n    Ok(Some(state))\n}\n\nfn validate_state(repo: &gix::Repository, state: &State) -> Result<()> {\n    repo.find_commit(state.base)\n        .context(\"could not find the recorded rebase base\")?;\n    repo.find_commit(state.onto)\n        .context(\"could not find the recorded rebase target\")?;\n    let scope: HashSet<_> = state.scope.iter().copied().collect();\n    let continuation_sources: HashSet<_> = state.continuation_sources.iter().copied().collect();\n    if scope.len() != state.scope.len() {\n        anyhow::bail!(\"the rebase state contains duplicate scope commits\");\n    }\n    if state.tips.iter().copied().collect::<HashSet<_>>().len() != state.tips.len() {\n        anyhow::bail!(\"the rebase state contains duplicate tips\");\n    }\n    let mut refs = HashSet::new();\n    for reference in &state.expected_refs {\n        if !refs.insert(reference.name.as_bstr()) {\n            anyhow::bail!(\"the rebase state contains duplicate refs\");\n        }\n        if !scope.contains(&reference.target) && reference.target != state.base && reference.target != state.onto {\n            anyhow::bail!(\"a captured ref does not logically point into the rebase scope\");\n        }\n    }\n    if let Some(name) = &state.head_ref\n        && !state\n            .expected_refs\n            .iter()\n            .any(|reference| reference.editable && reference.name == *name)","sourceCodeStart":764,"sourceCodeEnd":800,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-tix/src/edit/todo.rs#L764-L800","documentation":"During state validation, `validate_state` collects all `scope` OIDs into a `HashSet` and compares its size against the original vector. A size mismatch means the same commit OID was listed in `scope` more than once; since scope membership is a set concept, duplicates indicate a malformed state and validation aborts.","triggerScenarios":"`parse_state` (via validate_state, gix-tix/src/edit/todo.rs:782) parses a state file where two or more `scope <oid>` lines repeat the same commit OID.","commonSituations":"Hand-edited state duplicating a scope entry; scripts appending scope commits without deduplication; merged state files from divergent sessions.","solutions":["Deduplicate `scope` lines in the state file so each commit OID appears once.","Regenerate the state by restarting the rebase/edit operation.","Fix any automation that builds the scope list to deduplicate OIDs before writing."],"exampleFix":"// before (state file)\nscope 0123abc...\nscope 0123abc...\n// after\nscope 0123abc...","handlingStrategy":"validation","validationCode":"fn scope_lines_are_unique(text: &str) -> bool {\n    let ids: Vec<&str> = text.lines()\n        .filter_map(|l| l.strip_prefix(\"scope \"))\n        .collect();\n    ids.iter().collect::<std::collections::HashSet<_>>().len() == ids.len()\n}","typeGuard":null,"tryCatchPattern":"match todo::parse(state_text) {\n    Ok(state) => apply(state),\n    Err(e) if e.to_string().contains(\"duplicate scope commits\") => {\n        eprintln!(\"deduplicate scope lines before parsing\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Deduplicate OIDs before writing scope lines in generated state.","Use a set-based collector when building the scope list.","Round-trip validate generated state (write then parse) in tests."],"tags":["rebase","state-validation","duplicate-entries","git"],"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"}