gitbutlerapp/gitbutler · error · anyhow::Error

unterminated escape sequence in quoted message

Error message

unterminated escape sequence in quoted message

What it means

Raised by `parse_quoted_string` when the message ends immediately after a backslash with no following character — the escape was started but the input (line) ended, so the escape cannot be resolved.

Source

Thrown at crates/but-workspace/src/branch/integrate_branch_upstream/parsing.rs:215

            escaped = false;
            continue;
        }

        match ch {
            '\\' => escaped = true,
            '"' => {
                let trailing = input[index + ch.len_utf8()..].trim();
                if trailing.is_empty() {
                    return Ok(output);
                }
                bail!("unexpected trailing characters after quoted message");
            }
            other => output.push(other),
        }
    }

    if escaped {
        bail!("unterminated escape sequence in quoted message");
    }
    bail!("unterminated quoted message")
}

fn quote_message(message: &str) -> String {
    let mut out = String::from("\"");
    for ch in message.chars() {
        match ch {
            '\\' => out.push_str("\\\\"),
            '"' => out.push_str("\\\""),
            '\n' => out.push_str("\\n"),
            '\r' => out.push_str("\\r"),
            '\t' => out.push_str("\\t"),
            other => out.push(other),
        }
    }
    out.push('"');
    out

View on GitHub (pinned to caf1f223d3)

Solutions

  1. Double the trailing backslash (`\\`) or delete it.
  2. If the script looks truncated, re-render it and re-apply edits.

Example fix

# before
squash 4f2a 991b | message="path ends with \ 

# after
squash 4f2a 991b | message="path ends with \\"
Defensive patterns

Strategy: validation

Try / catch

if let Err(err) = parse_integration_steps_script(&script, &divergence) {
    if err.to_string().contains("unterminated escape sequence") {
        // line ends with a lone backslash; double it or remove it
    }
}

Prevention

When it happens

Trigger: A line like `squash 4f2a 991b | message="trailing backslash\` where the final backslash is the last character before end of input.

Common situations: Truncated scripts (editor cut off the line), or a literal Windows-path-style trailing backslash that was not doubled.

Related errors


AI-assisted analysis of gitbutlerapp/gitbutler@caf1f223d3 (2026-08-20). Data as JSON: /api/errors/6a7167e1e2039f93. Report an issue: GitHub.