{"record":{"id":"0982fd0d51400e50","repo":"junit-team/junit5","slug":"could-not-read-color-palette-properties","errorCode":null,"errorMessage":"Could not read color palette properties","messagePattern":"Could not read color palette properties","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"junit-platform-console/src/main/java/org/junit/platform/console/output/ColorPalette.java","lineNumber":112,"sourceCode":"\t\tthis.colorsToAnsiSequences = colorsToAnsiSequences;\n\t\tthis.disableAnsiColors = disableAnsiColors;\n\t}\n\n\tprivate static Map<Style, String> toOverrideMap(Properties properties) {\n\t\tMap<String, String> upperCaseProperties = properties.entrySet().stream().collect(Collectors.toMap(\n\t\t\tentry -> ((String) entry.getKey()).toUpperCase(Locale.ROOT), entry -> (String) entry.getValue()));\n\n\t\treturn Arrays.stream(Style.values()).filter(style -> upperCaseProperties.containsKey(style.name())).collect(\n\t\t\tCollectors.toMap(Function.identity(), style -> upperCaseProperties.get(style.name())));\n\t}\n\n\tprivate static Properties getProperties(Reader reader) {\n\t\tProperties properties = new Properties();\n\t\ttry {\n\t\t\tproperties.load(reader);\n\t\t}\n\t\tcatch (IOException e) {\n\t\t\tthrow new IllegalArgumentException(\"Could not read color palette properties\", e);\n\t\t}\n\t\treturn properties;\n\t}\n\n\tprivate static Properties getProperties(Path path) {\n\t\ttry (FileReader fileReader = new FileReader(path.toFile(), StandardCharsets.UTF_8)) {\n\t\t\treturn getProperties(fileReader);\n\t\t}\n\t\tcatch (IOException e) {\n\t\t\tthrow new IllegalArgumentException(\"Could not open color palette properties file\", e);\n\t\t}\n\t}\n\n\tpublic String paint(Style style, String text) {\n\t\treturn this.disableAnsiColors || style == Style.NONE ? text\n\t\t\t\t: getAnsiFormatter(style) + text + getAnsiFormatter(Style.NONE);\n\t}\n","sourceCodeStart":94,"sourceCodeEnd":130,"githubUrl":"https://github.com/junit-team/junit5/blob/f070c699a08b5d8393df9afd147af5c5e90bb21b/junit-platform-console/src/main/java/org/junit/platform/console/output/ColorPalette.java#L94-L130","documentation":"ColorPalette.getProperties(Reader) loads a Properties instance from a Reader and wraps any IOException from Properties.load() (e.g. malformed Unicode escape, a '\\u' followed by non-hex characters, or a reader already closed) as IllegalArgumentException. This is distinct from the file-open error (110): here the file was opened but its contents failed to parse as valid .properties.","triggerScenarios":"Supplying a color palette file (via --color-palette) whose content violates the .properties format — most commonly a malformed '\\uXXXX' Unicode escape sequence in a value, which Properties.load() rejects with IllegalArgumentException/IOException.","commonSituations":"Editing a palette file and introducing a bad escape (e.g. '\\u00' truncated, '\\uZZZZ'); copy-pasting ANSI sequences with backslashes that Java Properties interprets as escapes; saving with an editor that mangled encoding.","solutions":["Open the palette file and fix any malformed '\\uXXXX' escapes — they must be exactly four hex digits.","Validate the file with a Properties loader in a scratch program to surface the exact line, or run 'native2ascii' / an equivalent to confirm encoding.","Avoid backslashes in values or escape them as '\\\\' per .properties rules.","Re-save the file as UTF-8 if encoding corruption is suspected."],"exampleFix":"# before (palette.properties) — malformed escape\nSUCCESSFUL=\\u001B[1m\n# The '\\u001B' is interpreted by Properties as a Unicode escape and fails.\n# after — escape the backslash per .properties rules\nSUCCESSFUL=\\\\u001B[1m  # or omit the ANSI prefix entirely; ColorPalette expects numeric ANSI codes, not raw ESC sequences","handlingStrategy":"validation","validationCode":"// Validate the palette file parses cleanly as .properties before the launcher does.\nimport java.io.*; import java.util.*;\ntry (Reader r = new InputStreamReader(new FileInputStream(file), java.nio.charset.StandardCharsets.UTF_8)) {\n  Properties p = new Properties();\n  p.load(r); // throws on malformed \\uXXXX\n} catch (IOException e) {\n  throw new IllegalArgumentException(\"Palette file \" + file + \" is not valid .properties: \" + e.getMessage(), e);\n}\n","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Validate palette files in a scratch program before deploying them.","Avoid backslashes in palette values; escape them as '\\\\' if needed.","Save palette files as UTF-8 to avoid encoding-induced escape errors."],"tags":["color-palette","configuration","properties","console-launcher"],"backgroundTag":null,"analyzedSha":"f070c699a08b5d8393df9afd147af5c5e90bb21b","analyzedAt":"2026-08-11T20:31:00.530Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}