{"id":"56a7b19e70853a0c","repo":"junit-team/junit5","slug":"could-not-open-color-palette-properties-file","errorCode":null,"errorMessage":"Could not open color palette properties file","messagePattern":"Could not open color palette properties file","errorType":"exception","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"junit-platform-console/src/main/java/org/junit/platform/console/output/ColorPalette.java","lineNumber":122,"sourceCode":"\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\n\tprivate String getAnsiFormatter(Style style) {\n\t\treturn \"\\u001B[%sm\".formatted(this.colorsToAnsiSequences.get(style));\n\t}\n\n}\n","sourceCodeStart":104,"sourceCodeEnd":136,"githubUrl":"https://github.com/junit-team/junit5/blob/956246301e03d757539f7b76dd5a91f298637563/junit-platform-console/src/main/java/org/junit/platform/console/output/ColorPalette.java#L104-L136","documentation":"Thrown by getProperties(Path) at ColorPalette.java:117-123 when constructing a new FileReader(path.toFile(), UTF_8) fails with an IOException (e.g. file not found, permission denied). It is wrapped in an IllegalArgumentException. This is the file-access variant; the read-content variant is error 101.","triggerScenarios":"Calling new ColorPalette(path) where 'path' does not exist, is a directory rather than a regular file, is not readable due to OS permissions, or refers to a path on a filesystem that is unavailable. Triggered directly by the public ColorPalette(Path) constructor.","commonSituations":"Passing a relative path resolved against an unexpected working directory; pointing the console launcher's --color-palette option at a missing file; file deleted between discovery and read; running under a security manager / container that restricts file access; typo in the path string.","solutions":["Verify the file exists and is a regular readable file: Files.isReadable(path) && Files.isRegularFile(path) before constructing.","Use an absolute path or resolve the path explicitly against the intended base directory.","Check the caused-by IOException for the precise reason (NoSuchFileException, AccessDeniedException, etc.) and address it.","Confirm the path passed to the console launcher's palette option is correct and on the local filesystem."],"exampleFix":"// before\nPath p = Path.of(\"palette.properties\"); // wrong cwd\nColorPalette palette = new ColorPalette(p); // throws\n\n// after\nPath p = Path.of(System.getProperty(\"user.dir\")).resolve(\"config/palette.properties\");\nif (!Files.isReadable(p)) throw new IllegalStateException(\"palette not readable: \" + p);\nColorPalette palette = new ColorPalette(p);","handlingStrategy":"validation","validationCode":"Path palettePath = ...;\nif (!Files.isReadable(palettePath) || !Files.isRegularFile(palettePath)) {\n    throw new IllegalArgumentException(\"palette file missing/unreadable: \" + palettePath);\n}\nColorPalette palette = new ColorPalette(palettePath);","typeGuard":null,"tryCatchPattern":"try {\n    return new ColorPalette(palettePath);\n} catch (IllegalArgumentException e) {\n    throw new IllegalStateException(\"Cannot load palette from \" + palettePath, e.getCause());\n}","preventionTips":["Pass absolute paths to the console launcher's palette option.","Verify Files.isReadable before construction.","Use the file's canonical/real path to avoid working-directory surprises."],"tags":["junit-platform","console","io","filesystem","color-palette","configuration"],"analyzedSha":"956246301e03d757539f7b76dd5a91f298637563","analyzedAt":"2026-08-04T19:25:17.049Z","schemaVersion":2}