apple/pkl · error · InvalidUserDataException
Invalid test reporter
Error message
Invalid test reporter: '${input}'. Valid reporters: '<each reporter name, lowercase>'. What it means
toTestReporter converts a user-supplied test reporter name into a TestReporter enum value. If the input does not match any known reporter (case-insensitively), it throws InvalidUserDataException listing all valid reporter names in lowercase.
Solutions
- Use one of the exact reporter names listed in the error message (lowercase)
- Check the plugin documentation or TestReporter enum for the valid set
- Fix casing/typo in the reporter string in the build script
- If a reporter seems missing, verify you are on a plugin version that supports it
Example fix
// before
testReporters = listOf("junit-xmlx")
// after
testReporters = listOf("junit-xml") Defensive patterns
Strategy: validation
Validate before calling
// Java: validate against the enum before assignment
boolean valid = java.util.Arrays.stream(TestReporter.values())
.anyMatch(r -> r.name().toLowerCase(java.util.Locale.ROOT).equals(input.toLowerCase(java.util.Locale.ROOT))); Try / catch
try {
task.getTestReporters().add(PluginUtils.toTestReporter(input));
} catch (InvalidUserDataException e) {
logger.error("Invalid reporter '{}'; use one of: {}", input, e.getMessage());
throw new GradleException(e.getMessage());
} Prevention
- Copy reporter names from the error message's valid list verbatim
- Check the TestReporter enum in the plugin version you use — names can change between versions
- Keep reporter configuration in a shared convention plugin to avoid typos
When it happens
Trigger: Setting the testReports/test reporter property on Pkl Test tasks with a name not in the reporter enum (e.g. "junitxml" instead of "junit-xml" or whatever the enum defines).
Common situations: Typo in build.gradle testReporter setting, guessing reporter names, migrating CI configs from other tools (jest/mocha naming), or case/format mismatches.
Understand the failure class
Background: Invalid enum value errors: "Unknown type", "Invalid scope", "must be one of" — when a string is not on the library's allowed list — this error's family across 23 libraries.
Related errors
- Could not find a source set for code generator
- Failed to parse Pkl module file path
- No source modules specified.
- Unsupported value of type
- cannotFindCertFile
AI-assisted analysis of apple/pkl@f3efcbfc9b (2026-09-08).
Data as JSON: /api/errors/29003c79d042c543.
Report an issue: GitHub.
Appendix: source
Thrown at pkl-gradle/src/main/java/org/pkl/gradle/utils/PluginUtils.java:204
try {
return TestReporter.valueOf(inputStr.toUpperCase(Locale.ROOT));
} catch (IllegalArgumentException e) {
var sb = new StringBuilder("Invalid test reporter: '");
sb.append(inputStr).append("'. ");
sb.append("Valid reporters: ");
var isFirst = true;
// `enumEntries()` is not available in Kotlin versions below 1.8
//noinspection EnumValuesSoftDeprecateInJava
for (var value : TestReporter.values()) {
if (isFirst) {
isFirst = false;
} else {
sb.append(", ");
}
sb.append('\'').append(value.toString().toLowerCase(Locale.ROOT)).append('\'');
}
sb.append(".");
throw new InvalidUserDataException(sb.toString());
}
}
}
View on GitHub (pinned to f3efcbfc9b)