{"record":{"id":"001c2681169f2c4f","repo":"jdx/mise","slug":"incomplete-go-string-escape","errorCode":null,"errorMessage":"incomplete Go string escape","messagePattern":"incomplete Go string escape","errorType":"exception","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/533346cc374382b41ec5ff70536252b2e96e725c/src/task/workspace/go.rs#L239-L275","documentation":"escape_character reads a fixed number of digits (octal/hex/unicode escapes) from the char stream. If the string ends before the expected count is collected, the escape is truncated and mise bails rather than decoding partial data. This prevents silently mis-decoding truncated literals.","triggerScenarios":"A Go interpreted string literal ends mid-escape, e.g. \"\\x4\" or \"\\u00\" — fewer digits than the escape requires (3 octal, 2 hex, 4/8 unicode).","commonSituations":"Manually edited task args where trailing digits were deleted; template/interpolation consuming some of the escape digits; truncated config file.","solutions":["Supply the full digit count the escape requires (e.g. \\x0041 not \\x41... complete both hex digits).","Zero-pad short escapes: \\u0041 instead of \\u41.","Check the config file wasn't truncated or cut off at the end of the literal."],"exampleFix":"// before\nargs = [\"\\u00e9\"]   // 4 digits: valid — vs \"\\u0e9\" invalid\n// after\nargs = [\"\\u00e9\"]  // ensure all 4 hex digits present","handlingStrategy":"validation","validationCode":"function escapeComplete(inner, idx) {\n  // ensure \\x has 2 hex digits, \\u 4, \\U 8, octal 3\n  return inner.length >= idx + 2; // caller supplies required length\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Zero-pad short escapes (\\u0041 not \\u41).","Avoid letting templating/interpolation consume digits intended for escapes."],"tags":["go","parsing","string-escaping","truncated-escape"],"backgroundTag":"invalid-argument-format","analyzedSha":"533346cc374382b41ec5ff70536252b2e96e725c","analyzedAt":"2026-09-17T13:35:38.149Z","contentChangedAt":"2026-09-17T13:35:38.149Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}