jdx/mise · error

unsupported Go string escape \{escape}

Error message

unsupported Go string escape \{escape}

What it means

When unescaping an interpreted Go string, `unescape_go_string` matches the character after a backslash against the supported escape set (a, b, f, n, r, t, v, \\, \", octal, hex \x, and unicode \u/\U). Any other escape sequence throws this error naming the offending escape character.

Source

Thrown at src/task/workspace/go.rs:243

            'v' => '\u{000b}',
            '\\' => '\\',
            '\'' => '\'',
            '"' => '"',
            'x' => escape_character(&mut characters, 2, 16)?,
            'u' => escape_character(&mut characters, 4, 16)?,
            'U' => escape_character(&mut characters, 8, 16)?,
            digit @ '0'..='7' => {
                let mut digits = digit.to_string();
                for _ in 0..2 {
                    digits.push(
                        characters
                            .next()
                            .ok_or_else(|| eyre::eyre!("incomplete octal Go string escape"))?,
                    );
                }
                decoded_character(&digits, 8)?
            }
            _ => bail!("unsupported Go string escape \\{escape}"),
        };
        unescaped.push(escaped);
    }
    Ok(unescaped)
}

fn escape_character(
    characters: &mut std::str::Chars<'_>,
    length: usize,
    radix: u32,
) -> Result<char> {
    let digits = characters.take(length).collect::<String>();
    if digits.chars().count() != length {
        bail!("incomplete Go string escape");
    }
    decoded_character(&digits, radix)
}

View on GitHub (pinned to afd2eddd3a)

Solutions

  1. Remove the unnecessary backslash (most characters do not need escaping in Go strings)
  2. Replace the sequence with a supported Go escape (\n, \t, \\, \x41, \u0041, ...)
  3. Use a raw backtick string where escapes are not interpreted

Example fix

// before
module "exa\qmple"
// after
module "example"
Defensive patterns

Strategy: validation

Validate before calling

const GO_ESCAPES: [char; 11] = ['a','b','f','n','r','t','v','\\','"','\'','0'];
fn validate_escapes(inner: &str) -> Result<()> {
    let mut chars = inner.chars();
    while let Some(c) = chars.next() {
        if c == '\\' {
            let e = chars.next().context("trailing backslash")?;
            anyhow::ensure!(GO_ESCAPES.contains(&e) || e.is_ascii_digit() || e == 'x' || e == 'u' || e == 'U', "unsupported escape \\{e}");
        }
    }
    Ok(())
}

Prevention

When it happens

Trigger: A directive argument string containing an escape like `\q`, `\e`, `\/`, or `\0x` — i.e. a backslash followed by a character not in Go's escape table.

Common situations: Inventing escapes that other languages (JS, JSON) allow but Go does not; accidentally backslash-escaping a normal character; copy-pasting paths with stray 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 jdx/mise@afd2eddd3a (2026-09-09). Data as JSON: /api/errors/a6143ba93ac0cf44. Report an issue: GitHub.