{"id":"bc48cfbf33560b84","repo":"junit-team/junit5","slug":"cannot-override-the-standard-style-none","errorCode":null,"errorMessage":"Cannot override the standard style 'NONE'","messagePattern":"Cannot override the standard style 'NONE'","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"junit-platform-console/src/main/java/org/junit/platform/console/output/ColorPalette.java","lineNumber":76,"sourceCode":"\tprivate static Map<Style, String> singleColorPalette() {\n\t\tMap<Style, String> colorsToAnsiSequences = new EnumMap<>(Style.class);\n\t\tcolorsToAnsiSequences.put(Style.NONE, \"0\");\n\t\tcolorsToAnsiSequences.put(Style.SUCCESSFUL, \"1\");\n\t\tcolorsToAnsiSequences.put(Style.ABORTED, \"4\");\n\t\tcolorsToAnsiSequences.put(Style.FAILED, \"7\");\n\t\tcolorsToAnsiSequences.put(Style.SKIPPED, \"9\");\n\t\tcolorsToAnsiSequences.put(Style.CONTAINER, \"1\");\n\t\tcolorsToAnsiSequences.put(Style.TEST, \"0\");\n\t\tcolorsToAnsiSequences.put(Style.DYNAMIC, \"0\");\n\t\tcolorsToAnsiSequences.put(Style.REPORTED, \"2\");\n\t\treturn colorsToAnsiSequences;\n\t}\n\n\tColorPalette(Map<Style, String> overrides) {\n\t\tthis(defaultPalette(), false);\n\n\t\tif (overrides.containsKey(Style.NONE)) {\n\t\t\tthrow new IllegalArgumentException(\"Cannot override the standard style 'NONE'\");\n\t\t}\n\t\tthis.colorsToAnsiSequences.putAll(overrides);\n\t}\n\n\tColorPalette(Properties properties) {\n\t\tthis(toOverrideMap(properties));\n\t}\n\n\tColorPalette(Reader reader) {\n\t\tthis(getProperties(reader));\n\t}\n\n\tpublic ColorPalette(Path path) {\n\t\tthis(getProperties(path));\n\t}\n\n\tprivate ColorPalette(Map<Style, String> colorsToAnsiSequences, boolean disableAnsiColors) {\n\t\tthis.colorsToAnsiSequences = colorsToAnsiSequences;","sourceCodeStart":58,"sourceCodeEnd":94,"githubUrl":"https://github.com/junit-team/junit5/blob/956246301e03d757539f7b76dd5a91f298637563/junit-platform-console/src/main/java/org/junit/platform/console/output/ColorPalette.java#L58-L94","documentation":"Thrown by the ColorPalette override constructor when the supplied override map contains an entry for Style.NONE. NONE is the reserved ANSI reset style (code 0) that ColorPalette always sets itself in defaultPalette(); it cannot be redefined by the user because doing so would corrupt the reset terminator appended by paint(). The guard is an explicit IllegalArgumentException at ColorPalette.java:76.","triggerScenarios":"Constructing ColorPalette from a properties file, Reader, or Path (which all funnel into ColorPalette(Map<Style,String> overrides) at line 72) where the map produced by toOverrideMap() contains the key 'NONE'. Concretely: a junit-platform console color palette properties file containing the line 'NONE=31' or a hand-built Map passed via the package-private constructor.","commonSituations":"Authoring a custom ANSI color palette .properties file for the console launcher and mistakenly treating NONE as a style to recolor; copying a palette template that lists all Style enum values including NONE; the key matching is case-insensitive (toUpperCase(Locale.ROOT) in toOverrideMap at line 99-100) so a user writing 'none' thinking it inert still triggers it.","solutions":["Open the offending palette properties file and delete the 'NONE=...' line entirely; NONE is non-overridable by design.","If you intended a base/foreground color, use an overridable style: SUCCESSFUL, ABORTED, FAILED, SKIPPED, CONTAINER, TEST, DYNAMIC, REPORTED.","Validate the override map before constructing: remove or reject any key equal to Style.NONE.","If you must disable all ANSI coloring, use the predefined ColorPalette.NONE palette instead of overriding NONE."],"exampleFix":"// before\nProperties props = new Properties();\nprops.setProperty(\"NONE\", \"31\"); // or in file: NONE=31\nColorPalette palette = new ColorPalette(props); // throws\n\n// after\nProperties props = new Properties();\nprops.setProperty(\"FAILED\", \"31\");\nprops.setProperty(\"SUCCESSFUL\", \"32\");\nColorPalette palette = new ColorPalette(props); // ok","handlingStrategy":"validation","validationCode":"Map<Style,String> safeOverrides = new HashMap<>(overrides);\nsafeOverrides.remove(Style.NONE); // strip reserved key before constructing\nif (overrides.containsKey(Style.NONE)) {\n    throw new IllegalArgumentException(\"NONE is reserved; remove it from the override map\");\n}\nColorPalette palette = new ColorPalette(safeOverrides);","typeGuard":"static boolean hasNoReservedStyleKeys(Map<Style,String> overrides) {\n    return !overrides.containsKey(Style.NONE);\n}","tryCatchPattern":"try {\n    return new ColorPalette(overrides);\n} catch (IllegalArgumentException e) {\n    if (e.getMessage().contains(\"NONE\")) {\n        overrides.remove(Style.NONE);\n        return new ColorPalette(overrides);\n    }\n    throw e;\n}","preventionTips":["When editing a palette properties file, only include overridable Style names: SUCCESSFUL, ABORTED, FAILED, SKIPPED, CONTAINER, TEST, DYNAMIC, REPORTED.","Never emit NONE from tooling that generates palette files.","Unit-test palette construction against your properties file in CI."],"tags":["junit-platform","console","ansi","color-palette","configuration"],"analyzedSha":"956246301e03d757539f7b76dd5a91f298637563","analyzedAt":"2026-08-04T19:25:17.049Z","schemaVersion":2}