{"record":{"id":"00a8b2c8dbadebce","repo":"GitoxideLabs/gitoxide","slug":"commentchar-must-not-contain-a-line-ending","errorCode":null,"errorMessage":"CommentChar must not contain a line ending","messagePattern":"CommentChar must not contain a line ending","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"gix-tix/src/edit/reword.rs","lineNumber":359,"sourceCode":"    out.extend_from_slice(label);\n    out.extend_from_slice(\n        time.format(gix::date::time::format::ISO8601)\n            .context(\"could not format commit date\")?\n            .as_bytes(),\n    );\n    out.push(b'\\n');\n    Ok(())\n}\n\npub(super) fn parse(input: &[u8]) -> Result<Edit<'_>> {\n    let mut parts = input.splitn(6, |byte| *byte == b'\\n');\n    let author = header(parts.next(), AUTHOR)?;\n    let author_time = date(header(parts.next(), AUTHOR_DATE)?, \"author\")?;\n    let committer = header(parts.next(), COMMITTER)?;\n    let committer_time = date(header(parts.next(), COMMITTER_DATE)?, \"committer\")?;\n    let comment_char = header(parts.next(), COMMENT_CHAR)?;\n    if comment_char.contains(&b'\\r') {\n        anyhow::bail!(\"CommentChar must not contain a line ending\");\n    }\n    let remainder = parts.next().context(\"the enrichment headers are missing\")?;\n    let mut enrichment = crate::enrich::Headers::default();\n    let mut todo_seen = false;\n    let mut message_seen = false;\n    let mut message_offset = None;\n    let mut consumed = 0;\n    for line in remainder.lines_with_terminator() {\n        consumed += line.len();\n        let line = trim_cr(line.strip_suffix(b\"\\n\").unwrap_or(line));\n        if line.is_empty() {\n            message_offset = Some(consumed);\n            break;\n        }\n        if line.starts_with(comment_char) {\n            continue;\n        }\n        if line == TODO {","sourceCodeStart":341,"sourceCodeEnd":377,"githubUrl":"https://github.com/GitoxideLabs/gitoxide/blob/e73179060badf27222d790981fac3f84c1830a7e/gix-tix/src/edit/reword.rs#L341-L377","documentation":"The reword edit document carries enrichment headers, one of which is `CommentChar`. Because comment lines are detected by line-start prefix matching, a comment character containing `\\r` or `\\n` would corrupt line parsing. `parse` therefore rejects any CommentChar value containing a line ending with this error.","triggerScenarios":"Calling `parse` (via `apply_conflict_reporting`, `parses_the_edit_document`, `document_does_not_repeat_existing_agent_trailers`, or `parses_bare_todo_and_single_line_message_headers`) on a document whose `CommentChar` header value contains a `\\r` (checked here) or other line-ending byte.","commonSituations":"A document generated on/for Windows with CRLF leaking into the header value; a custom comment character mistakenly configured as a multi-character or control-character string; hand-edited enrichment headers.","solutions":["Set CommentChar to a single non-line-ending character (e.g. `#`).","Normalize line endings (CRLF → LF) before writing/parsing the document.","Regenerate the edit document via `document()` instead of hand-editing headers."],"exampleFix":"// before (document header with CR leaking in)\nCommentChar: #\\r\n// after (normalize before parsing)\nlet normalized: Vec<u8> = edited.iter().copied().filter(|&b| b != b'\\r').collect();\nparse(&normalized)?;","handlingStrategy":"validation","validationCode":"fn comment_char_is_safe(value: &[u8]) -> bool {\n    !value.contains(&b'\\n') && !value.contains(&b'\\r')\n}","typeGuard":null,"tryCatchPattern":"match parse(&edited) {\n    Ok(doc) => doc,\n    Err(e) if e.to_string().contains(\"CommentChar\") => {\n        let sanitized: Vec<u8> = edited.iter().copied().filter(|&b| b != b'\\r').collect();\n        parse(&sanitized)\n    }\n    Err(e) => return Err(e),\n}","preventionTips":["Always use a single printable character (typically `#`) as CommentChar.","Normalize CRLF to LF before writing or parsing edit documents.","Generate documents via `document()` instead of hand-writing headers."],"tags":["git","parsing","validation","comment-char","encoding"],"backgroundTag":"invalid-argument-value","analyzedSha":"e73179060badf27222d790981fac3f84c1830a7e","analyzedAt":"2026-09-08T11:26:50.865Z","contentChangedAt":"2026-09-08T11:26:50.865Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}