gitbutlerapp/gitbutler · error

unsupported escape sequence '\

Error message

unsupported escape sequence '\{other}'

What it means

Inside a quoted `message="..."` clause, only a fixed set of escape sequences is supported: `\\`, `\"`, `\n`, `\r`, `\t`. Any other backslash-prefixed character raises this error, wrapped as `line N: invalid squash message: unsupported escape sequence '\x'`. The parser is strict so that rendered scripts round-trip exactly.

Solutions

  1. Replace unsupported escapes with the allowed set: `\\` for backslash, `\"` for quote, `\n`, `\r`, `\t` for control characters.
  2. Write literal characters directly instead of escaping them (e.g. type `/` instead of `\/`, real characters instead of `\uXXXX`).
  3. Double any literal backslashes in the message (e.g. a path `C:\dir` becomes `C:\\dir`).
  4. Remove the message clause if complex escaping is not worth it; the step keeps the default commit message.

Example fix

// before (script text)
squash 2222222 3333333 | message="path C:\dir"
// after
squash 2222222 3333333 | message="path C:\\dir"
Defensive patterns

Strategy: validation

Validate before calling

function validateEscapes(line: string, lineNo: number): string | null {
  const m = line.match(/\|\s*message="((?:[^"\\]|\\.)*)"/);
  if (!m) return null;
  const bad = m[1].match(/\\(?!\\|"|n|r|t)/g);
  if (bad) return `line ${lineNo}: unsupported escape sequence near ${bad[0]}`;
  return null;
}

Type guard

const escapesAreSupported = (line: string): boolean => {
  const m = line.match(/\|\s*message="((?:[^"\\]|\\.)*)"/);
  return !m || !/\\(?!\\|"|n|r|t)/.test(m[1]);
};

Try / catch

try {
  const steps = await parseIntegrationScript(script, divergence);
} catch (err) {
  const m = /unsupported escape sequence '\\(.)'/.exec(String(err));
  if (m) showEditorHint(`escape \\${m[1]} is not supported; use \\\\, \\" , \\n, \\r, or \\t`);
  else throw err;
}

Prevention

When it happens

Trigger: Calling parse_integration_steps_script with a squash message containing an unsupported escape such as `\0`, `\u0041`, `\/`, or a trailing lone backslash before a character not in the allowed set.

Common situations: Users paste shell-escaped or JSON-style strings (`\uXXXX` unicode escapes) into the message, or add a Windows-style path with `\` separators without doubling the backslashes.

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


AI-assisted analysis of gitbutlerapp/gitbutler@58e5313667 (2026-09-18). Data as JSON: /api/errors/88bb5df34c4b51e0. Report an issue: GitHub.

Appendix: source

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

    parse_quoted_string(value)
}

fn parse_quoted_string(input: &str) -> Result<String> {
    if !input.starts_with('"') {
        bail!("message must start with a double quote");
    }

    let mut output = String::new();
    let mut escaped = false;
    for (index, ch) in input.char_indices().skip(1) {
        if escaped {
            let resolved = match ch {
                '\\' => '\\',
                '"' => '"',
                '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),
        }
    }

View on GitHub (pinned to 58e5313667)