{"record":{"id":"a64436ee5a9862be","repo":"GitoxideLabs/gitoxide","slug":"a-quoted-reference-name-is-not-closed","errorCode":null,"errorMessage":"a quoted reference name is not closed","messagePattern":"a quoted reference name is not closed","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-tix/src/edit/todo.rs","lineNumber":1100,"sourceCode":"    let mut quoted = false;\n    let mut escaped = false;\n    for (index, byte) in body.bytes().enumerate() {\n        if escaped {\n            escaped = false;\n            continue;\n        }\n        match byte {\n            b'\\\\' if quoted => escaped = true,\n            b'\"' => quoted = !quoted,\n            b',' if !quoted => {\n                ranges.push(&body[start..index]);\n                start = index + 1;\n            }\n            _ => {}\n        }\n    }\n    if quoted || escaped {\n        anyhow::bail!(\"a quoted reference name is not closed\");\n    }\n    ranges.push(&body[start..]);\n    let mut out = Vec::with_capacity(ranges.len());\n    for item in ranges {\n        let item = item.trim();\n        if item.is_empty() {\n            anyhow::bail!(\"a reference line contains an empty name\");\n        }\n        let (marked, item) = item.strip_prefix('@').map_or((false, item), |item| (true, item));\n        let encoded = item.as_bytes().as_bstr();\n        let (name, consumed) = gix::quote::ansi_c::undo(encoded)\n            .map_err(gix::Exn::into_error)\n            .context(\"could not unquote a reference name\")?;\n        if !encoded[consumed..].trim().is_empty() {\n            anyhow::bail!(\"a reference name has trailing data\");\n        }\n        if name.is_empty() {\n            anyhow::bail!(\"a reference name is empty\");","sourceCodeStart":1082,"sourceCodeEnd":1118,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-tix/src/edit/todo.rs#L1082-L1118","documentation":"`parse_ref_line` parses a `(name1, name2, …)` reference line with C-style quoting and backslash escapes. If, after scanning the whole body, the parser is still inside a quoted section or a pending escape (an odd number of `\"` or a trailing `\\`), it throws this error because the token stream is unterminated and names cannot be split reliably.","triggerScenarios":"Calling `parse` with a reference line like `(\"refs/heads/main)` or `(\"branch \")` with a missing closing quote, or a name ending in a lone backslash `(refs/heads/main\\)`.`","commonSituations":"Manual editing of the reference line drops a closing quote; a shell/editor eats a trailing backslash; quoting rules from other tools are copied in (e.g. single quotes, which this parser does not treat as quotes).","solutions":["Add the missing closing `\"` around the quoted reference name.","Remove the dangling trailing `\\` or double it (`\\\\`) if a literal backslash is intended.","Avoid quoting altogether — plain, comma-separated reference names need no quotes."],"exampleFix":"// before\n(\"refs/heads/main, refs/tags/v1)\n\n// after\n(\"refs/heads/main\", \"refs/tags/v1\")","handlingStrategy":"validation","validationCode":"// Rust: quick balance check for quotes/backslashes in a reference-line body\nfn quotes_balanced(body: &str) -> bool {\n    let mut quoted = false;\n    let mut escaped = false;\n    for b in body.bytes() {\n        if escaped { escaped = false; continue; }\n        match b {\n            b'\\\\' if quoted => escaped = true,\n            b'\"' => quoted = !quoted,\n            _ => {}\n        }\n    }\n    !quoted && !escaped\n}","typeGuard":null,"tryCatchPattern":"match parse_plan(&repo, text) {\n    Ok(plan) => apply(plan),\n    Err(e) if e.to_string().contains(\"quoted reference name is not closed\") => {\n        eprintln!(\"Fix unbalanced quotes/backslash in the (…) reference line.\");\n        Err(e)\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Keep reference names unquoted unless they contain spaces or special characters.","Count your quotes: each `\"` must be closed on the same line.","Do not end a name with a lone backslash."],"tags":["parsing","quoting","refs"],"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"}