{"record":{"id":"1b74289cad896096","repo":"GitoxideLabs/gitoxide","slug":"a-captured-ref-name-has-trailing-data","errorCode":null,"errorMessage":"a captured ref name has trailing data","messagePattern":"a captured ref name has trailing data","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-tix/src/edit/todo.rs","lineNumber":735,"sourceCode":"            }\n            \"edit-refs\" => edit_refs = value.parse()?,\n            \"ref\" => {\n                let (old, value) = value.split_once(' ').context(\"a captured ref has no target\")?;\n                let (target, value) = value.split_once(' ').context(\"a captured ref has no follow mode\")?;\n                let old = (old != \"-\").then(|| ObjectId::from_hex(old.as_bytes())).transpose()?;\n                let target = ObjectId::from_hex(target.as_bytes())?;\n                let (follows_tip, value) = value.split_once(' ').context(\"a captured ref has no name\")?;\n                let follows_tip = follows_tip.parse()?;\n                let (editable, name) = value\n                    .split_once(' ')\n                    .and_then(|(editable, name)| editable.parse::<bool>().ok().map(|editable| (editable, name)))\n                    .unwrap_or((false, value));\n                let encoded_name = name.as_bytes().as_bstr();\n                let (name, consumed) = gix::quote::ansi_c::undo(encoded_name)\n                    .map_err(gix::Exn::into_error)\n                    .context(\"could not unquote a captured ref name\")?;\n                if !encoded_name[consumed..].trim().is_empty() {\n                    anyhow::bail!(\"a captured ref name has trailing data\");\n                }\n                let name = gix::refs::FullName::try_from(name.as_ref()).context(\"a captured ref name is invalid\")?;\n                expected_refs.push(rebase::ExpectedRef {\n                    name,\n                    old,\n                    target,\n                    new: old,\n                    follows_tip,\n                    editable,\n                    placement: None,\n                });\n            }\n            \"resolved\" => {\n                if resolved.replace(ObjectId::from_hex(value.as_bytes())?).is_some() {\n                    anyhow::bail!(\"the rebase state repeats its resolved conflict\");\n                }\n            }\n            \"continuation-source\" => continuation_sources.push(ObjectId::from_hex(value.as_bytes())?),","sourceCodeStart":717,"sourceCodeEnd":753,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-tix/src/edit/todo.rs#L717-L753","documentation":"For each `ref` line captured in the rebase state, `parse_state` unquotes the ref name with `gix::quote::ansi_c::undo` and requires the remaining bytes after the quoted name to be empty after trimming. Leftover characters mean the captured ref name is followed by unexpected data, so the state is rejected as malformed.","triggerScenarios":"`parse_state` (gix-tix/src/edit/todo.rs:735) parsing a `ref <old> <target> <quoted-name>` line where the name field carries trailing tokens, e.g. an extra value or a mangled quote sequence that fails to consume the whole name field.","commonSituations":"Hand-edited `ref` lines; names containing spaces that were not properly C-quoted; corruption from interrupted writes; mismatched state format versions.","solutions":["Fix the `ref` line so the name is a single C-quoted fully-qualified ref (quote names containing spaces or special characters).","Remove any stray characters after the quoted ref name.","Regenerate the state by re-running the rebase/edit operation."],"exampleFix":"// before (state file)\nref abc123 fast-forward refs/heads/wip extra\n// after\nref abc123 fast-forward \"refs/heads/wip\"","handlingStrategy":"validation","validationCode":"fn ref_name_field_is_clean(value: &str) -> bool {\n    value.split_whitespace().count() == 3\n}","typeGuard":null,"tryCatchPattern":"match todo::parse(state_text) {\n    Ok(state) => apply(state),\n    Err(e) if e.to_string().contains(\"captured ref name has trailing data\") => {\n        eprintln!(\"fix the ref line: quote the name, remove trailing tokens\");\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Always C-quote captured ref names (gix::quote::ansi_c) when writing state.","Validate each ref line has exactly old/target/name fields before saving.","Test state round-trips (write then parse) in automation."],"tags":["rebase","state-parsing","ref-format","git"],"backgroundTag":"invalid-argument-format","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"}