gitbutlerapp/gitbutler · error
unexpected trailing characters after quoted message
Error message
unexpected trailing characters after quoted message
What it means
After the closing double quote of a `message="..."` clause, nothing but whitespace may follow on the line. If non-whitespace characters appear after the closing quote, the parser raises this error so no message content is silently truncated or ignored. It surfaces wrapped as `line N: invalid squash message: unexpected trailing characters after quoted message`.
Solutions
- Remove everything after the closing double quote of the message clause.
- Move trailing remarks to their own line starting with `#`, which the parser ignores.
- If a second clause was accidentally duplicated, delete the extra `message="..."` occurrence.
- Ensure the message itself has all content inside a single pair of escaped quotes.
Example fix
// before (script text) squash 2222222 3333333 | message="done" extra // after squash 2222222 3333333 | message="done" # extra
Defensive patterns
Strategy: validation
Validate before calling
function validateNoTrailing(line: string, lineNo: number): string | null {
const m = line.match(/\|\s*message="(?:[^"\\]|\\.)*"(.*)$/);
if (m && m[1].trim() !== '') return `line ${lineNo}: unexpected trailing characters after quoted message`;
return null;
} Type guard
const noTrailingAfterMessage = (line: string): boolean => {
const m = line.match(/\|\s*message="(?:[^"\\]|\\.)*"(.*)$/);
return !m || m[1].trim() === '';
}; Try / catch
try {
const steps = await parseIntegrationScript(script, divergence);
} catch (err) {
const m = /line (\d+): invalid squash message: unexpected trailing characters/.exec(String(err));
if (m) showEditorErrorAtLine(Number(m[1]), 'remove content after the closing quote of message="..."');
else throw err;
} Prevention
- End squash lines immediately after the closing quote of the message.
- Put annotations on separate `#` comment lines, never after the message clause.
- Avoid duplicating `message=` clauses; one quoted message per squash line.
When it happens
Trigger: Calling parse_integration_steps_script with a squash line like `squash a b | message="done" extra` or with two message clauses (`message="a" message="b"`). Unterminated quotes can also lead here indirectly (they instead raise `unterminated quoted message`).
Common situations: Users append comments after the message (comments must be on their own `#` line), paste duplicated clauses, or an editor leaves stray characters after the closing quote.
Understand the failure class
Background: "Invalid ... format", "must be in format X", "does not look like a ..." — invalid argument format errors across CLI tools and libraries — this error's family across 17 libraries.
Related errors
- message must start with a double quote
- line : merge does not accept a message clause
- line : merge requires exactly one commit
- line : pick requires exactly one commit
- line : squash requires at least two commits
AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18).
Data as JSON: /api/errors/2995625d07ffdf2d.
Report an issue: GitHub.
Appendix: source
Thrown at crates/but-workspace/src/branch/integrate_branch_upstream/parsing.rs:208
'"' => '"',
'n' => '\n',
'r' => '\r',
't' => '\t',
other => bail!("unsupported escape sequence '\\{other}'"),
};
output.push(resolved);
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"),View on GitHub (pinned to 58e5313667)