{"record":{"id":"001c2681169f2c4f","repo":"jdx/mise","slug":"incomplete-go-string-escape","errorCode":null,"errorMessage":"incomplete Go string escape","messagePattern":"incomplete Go string escape","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/task/workspace/go.rs","lineNumber":257,"sourceCode":"                    );\n                }\n                decoded_character(&digits, 8)?\n            }\n            _ => bail!(\"unsupported Go string escape \\\\{escape}\"),\n        };\n        unescaped.push(escaped);\n    }\n    Ok(unescaped)\n}\n\nfn escape_character(\n    characters: &mut std::str::Chars<'_>,\n    length: usize,\n    radix: u32,\n) -> Result<char> {\n    let digits = characters.take(length).collect::<String>();\n    if digits.chars().count() != length {\n        bail!(\"incomplete Go string escape\");\n    }\n    decoded_character(&digits, radix)\n}\n\nfn decoded_character(digits: &str, radix: u32) -> Result<char> {\n    let value = u32::from_str_radix(digits, radix)\n        .wrap_err_with(|| format!(\"invalid Go string escape {digits:?}\"))?;\n    char::from_u32(value).ok_or_else(|| eyre::eyre!(\"invalid Go character escape {digits:?}\"))\n}\n\nfn strip_comment(line: &str) -> &str {\n    let mut quote = None;\n    let mut escaped = false;\n    for (index, character) in line.char_indices() {\n        match quote {\n            Some('\"') if escaped => escaped = false,\n            Some('\"') if character == '\\\\' => escaped = true,\n            Some(delimiter) if character == delimiter => quote = None,","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/jdx/mise/blob/afd2eddd3a50c16190efc1c7e94404b48f72af57/src/task/workspace/go.rs#L239-L275","documentation":"`escape_character` reads a fixed number of digits (for octal, hex \\x, \\u, or \\U escapes) from the string's character iterator. If fewer than the required digits remain before the string ends, the escape is truncated and this error is thrown.","triggerScenarios":"An interpreted Go string ending mid-escape, e.g. `\\x4` (needs 2 hex digits), `\\u00` (needs 4), `\\U0000` (needs 8), or `\\40` octal with digits cut off by the closing quote.","commonSituations":"Manually typing hex/unicode escapes and losing digits; a truncating editor or copy-paste clipping the tail of the string; templating that dropped trailing characters.","solutions":["Complete the escape with the required number of digits (2 for \\x/octal-count, 4 for \\u, 8 for \\U)","Shorten to the compact \\x form if the codepoint fits, reducing digit-count mistakes","Simplify to a plain character or a named escape like \\n instead of a numeric one"],"exampleFix":"// before\nmodule \"ex\\x4mple\"\n// after\nmodule \"ex\\x4dmple\"\n","handlingStrategy":"validation","validationCode":"fn validate_escape_digit_counts(inner: &str) -> Result<()> {\n    let need = |c: char| match c { 'x' => 2, 'u' => 4, 'U' => 8, _ => 0 };\n    let mut chars = inner.chars().peekable();\n    while let Some(c) = chars.next() {\n        if c == '\\\\' {\n            if let Some(n) = chars.peek().copied().map(need) {\n                anyhow::ensure!(chars.as_str().chars().take(n).count() == n, \"incomplete escape at end of string\");\n            }\n        }\n    }\n    Ok(())\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Write numeric escapes with the full digit count in one edit","Prefer \\u over \\U when the codepoint fits in 4 hex digits","Double-check strings edited near end-of-line for clipped digits"],"tags":["parsing","go","strings","escaping"],"backgroundTag":"invalid-argument-format","analyzedSha":"afd2eddd3a50c16190efc1c7e94404b48f72af57","analyzedAt":"2026-09-09T01:38:25.179Z","contentChangedAt":"2026-09-09T01:38:25.179Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}