{"record":{"id":"5774c7479a20daa3","repo":"apache/maven","slug":"unable-to-parse-unicode-value-s","errorCode":null,"errorMessage":"Unable to parse unicode value: %s","messagePattern":"Unable to parse unicode value: (.+?)","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"compat/maven-embedder/src/main/java/org/apache/maven/cli/props/MavenProperties.java","lineNumber":603,"sourceCode":"        boolean hadSlash = false;\n        boolean inUnicode = false;\n        for (int i = 0; i < sz; i++) {\n            char ch = str.charAt(i);\n            if (inUnicode) {\n                // if in unicode, then we're reading unicode\n                // values in somehow\n                unicode.append(ch);\n                if (unicode.length() == UNICODE_LEN) {\n                    // unicode now contains the four hex digits\n                    // which represents our unicode character\n                    try {\n                        int value = Integer.parseInt(unicode.toString(), HEX_RADIX);\n                        out.append((char) value);\n                        unicode.setLength(0);\n                        inUnicode = false;\n                        hadSlash = false;\n                    } catch (NumberFormatException nfe) {\n                        throw new IllegalArgumentException(\"Unable to parse unicode value: \" + unicode, nfe);\n                    }\n                }\n                continue;\n            }\n\n            if (hadSlash) {\n                // handle an escaped value\n                hadSlash = false;\n                switch (ch) {\n                    case '\\\\':\n                        out.append('\\\\');\n                        break;\n                    case '\\'':\n                        out.append('\\'');\n                        break;\n                    case '\\\"':\n                        out.append('\"');\n                        break;","sourceCodeStart":585,"sourceCodeEnd":621,"githubUrl":"https://github.com/apache/maven/blob/e4093d4e120eac99d6bdce5ba67cace2f3085c97/compat/maven-embedder/src/main/java/org/apache/maven/cli/props/MavenProperties.java#L585-L621","documentation":"Maven's properties loader (MavenProperties, the java-properties parser) handles \\uXXXX escapes: after a backslash-u it accumulates exactly four characters and converts them with Integer.parseInt(digits, 16). If those four characters are not valid hexadecimal digits, the NumberFormatException is rethrown as IllegalArgumentException 'Unable to parse unicode value: <digits>'. This is the standard .properties escaping rule, identical to java.util.Properties: a backslash before 'u' always starts a unicode escape.","triggerScenarios":"A properties file (e.g. loaded by Maven tooling) containing a Windows path like C:\\users\\john — the sequence \\user makes the parser read 'sers' as the four hex digits and fail. Any stray backslash immediately followed by 'u' that is not a genuine 4-hex-digit escape (e.g. \\utility, C:\\usr, log paths like ...\\upload).","commonSituations":"Windows machines writing absolute paths into properties files with single backslashes. Copying Windows examples into cross-platform config. Config generators that interpolate backslashes without doubling them.","solutions":["Escape backslashes: write C:\\\\users\\\\john (doubled) in the properties file.","Prefer forward slashes for paths in properties files: C:/users/john — Java APIs accept them on Windows.","Find the offending line: search the loaded file(s) for the regex \\\\u followed by a non-4-hex sequence.","If a genuine unicode escape was intended, supply exactly four hex digits (\\u00e9)."],"exampleFix":"# before (properties file)\noutput.dir=C:\\users\\john\\out\n\n# after\noutput.dir=C:/users/john/out\n# or\noutput.dir=C:\\\\users\\\\john\\\\out","handlingStrategy":"validation","validationCode":"// Validate a properties file before handing it to Maven tooling\nstatic void assertNoBadUnicodeEscape(Path f) throws IOException {\n    Pattern bad = Pattern.compile(\"\\\\\\\\u(?![0-9a-fA-F]{4})\");\n    for (String line : Files.readAllLines(f)) {\n        String l = line.replaceAll(\"\\\\\\\\\\\\\\\\\", \"\"); // skip escaped backslashes\n        if (bad.matcher(l).find()) {\n            throw new IllegalArgumentException(\"Stray backslash-u in \" + f + \": \" + line);\n        }\n    }\n}","typeGuard":null,"tryCatchPattern":"try {\n    props.load(reader);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Unable to parse unicode value\")) {\n        // report the offending file/line: a \\u not followed by 4 hex digits; fix escaping and reload\n    }\n    throw e;\n}","preventionTips":["Always escape backslashes in .properties files (C:\\\\dir) or write forward slashes for paths.","Lint properties files for the \\\\u(?![0-9a-fA-F]{4}) pattern in CI.","Remember \\u always starts an escape in .properties syntax — there is no way to write a literal backslash-u otherwise."],"tags":["maven","properties","escaping","unicode","windows-paths","parse-error"],"backgroundTag":"malformed-unicode-escape","analyzedSha":"e4093d4e120eac99d6bdce5ba67cace2f3085c97","analyzedAt":"2026-08-21T22:58:24.034Z","schemaVersion":2},"datasetVersion":"2026-08-21T23:17:16.201Z"}