junit-team/junit5 · error · IllegalArgumentException

Could not open color palette properties file

Error message

Could not open color palette properties file

What it means

ColorPalette.getProperties(Path) opens the palette properties file via FileReader. If the file does not exist, is a directory, or cannot be read, an IOException is wrapped as IllegalArgumentException. This is the file-open failure; the read/parse failure is a separate message (109).

Solutions

  1. Verify the path exists and is a regular file: Files.isRegularFile(path) && Files.isReadable(path).
  2. Use an absolute path to avoid working-directory ambiguity.
  3. Fix permissions/ownership so the process can read the file, or run as the appropriate user.
  4. If the palette is optional, drop --color-palette to fall back to the default palette.

Example fix

# before
java -jar junit-platform-console-standalone.jar execute --color-palette ./missing.properties
# after
ls /home/me/palette.properties  # confirm it exists
java -jar junit-platform-console-standalone.jar execute --color-palette /home/me/palette.properties
Defensive patterns

Strategy: validation

Validate before calling

// Before passing --color-palette, confirm the file exists and is readable.
import java.nio.file.*;
Path p = Paths.get(palettePath);
if (!Files.isRegularFile(p)) throw new IllegalArgumentException("palette file missing or not a regular file: " + p);
if (!Files.isReadable(p))  throw new IllegalArgumentException("palette file not readable: " + p);

Prevention

When it happens

Trigger: Passing --color-palette a path that does not exist, points to a directory, or is unreadable due to permissions. FileReader construction fails before any properties parsing.

Common situations: Typo in the palette file path; relative path resolved against an unexpected working directory; file deleted or moved between config time and run; permissions stripped (e.g. containerized run as a different user).

Related errors


AI-assisted analysis of junit-team/junit5@f070c699a0 (2026-08-11). Data as JSON: /api/errors/56a7b19e70853a0c. Report an issue: GitHub.

Appendix: source

Thrown at junit-platform-console/src/main/java/org/junit/platform/console/output/ColorPalette.java:122

	}

	private static Properties getProperties(Reader reader) {
		Properties properties = new Properties();
		try {
			properties.load(reader);
		}
		catch (IOException e) {
			throw new IllegalArgumentException("Could not read color palette properties", e);
		}
		return properties;
	}

	private static Properties getProperties(Path path) {
		try (FileReader fileReader = new FileReader(path.toFile(), StandardCharsets.UTF_8)) {
			return getProperties(fileReader);
		}
		catch (IOException e) {
			throw new IllegalArgumentException("Could not open color palette properties file", e);
		}
	}

	public String paint(Style style, String text) {
		return this.disableAnsiColors || style == Style.NONE ? text
				: getAnsiFormatter(style) + text + getAnsiFormatter(Style.NONE);
	}

	private String getAnsiFormatter(Style style) {
		return "\u001B[%sm".formatted(this.colorsToAnsiSequences.get(style));
	}

}

View on GitHub (pinned to f070c699a0)