{"record":{"id":"13ed00353d406d33","repo":"junit-team/junit5","slug":"invalid-s-s-set-via-the-s-configuration-par","errorCode":null,"errorMessage":"Invalid %s '%s' set via the '%s' configuration parameter.","messagePattern":"Invalid (.+?) '(.+?)' set via the '(.+?)' configuration parameter\\.","errorType":"exception","errorClass":"JUnitException","httpStatus":null,"severity":"error","filePath":"junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/config/EnumConfigurationParameterConverter.java","lineNumber":61,"sourceCode":"\t\treturn configParams.get(key) //\n\t\t\t\t.map(value -> convert(key, value));\n\t}\n\n\tpublic Optional<E> get(ExtensionContext extensionContext, String key) {\n\t\treturn extensionContext.getConfigurationParameter(key, value -> convert(key, value));\n\t}\n\n\tprivate E convert(String key, String value) {\n\t\tString constantName = null;\n\t\ttry {\n\t\t\tconstantName = value.strip().toUpperCase(Locale.ROOT);\n\t\t\tE result = Enum.valueOf(enumType, constantName);\n\t\t\tlogger.config(() -> \"Using %s '%s' set via the '%s' configuration parameter.\".formatted(enumDisplayName,\n\t\t\t\tresult, key));\n\t\t\treturn result;\n\t\t}\n\t\tcatch (Exception ex) {\n\t\t\tthrow new JUnitException(\"Invalid %s '%s' set via the '%s' configuration parameter.\".formatted(\n\t\t\t\tenumDisplayName, constantName, key));\n\t\t}\n\t}\n\n}\n","sourceCodeStart":43,"sourceCodeEnd":67,"githubUrl":"https://github.com/junit-team/junit5/blob/f070c699a08b5d8393df9afd147af5c5e90bb21b/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/config/EnumConfigurationParameterConverter.java#L43-L67","documentation":"JUnitException from EnumConfigurationParameterConverter.convert, thrown when a configuration parameter that should map to an enum constant cannot be parsed. The converter upper-cases and strips the supplied value, then calls Enum.valueOf; if that throws (no such constant), the whole thing is wrapped as a JUnitException naming the enum display name, the offending value, and the config key.","triggerScenarios":"Setting a JUnit configuration parameter (e.g. junit.jupiter.execution.parallel.enabled, junit.jupiter.testclass.order.default, junit.jupiter.displayname.generator.default) to a value that is not a valid constant of the expected enum (e.g. typo, wrong case even after normalization, or a constant removed in a newer version).","commonSituations":"Typos in junit.properties or -D flags; copying a value from an older JUnit version whose enum constant was renamed/removed; locale-specific casing surprises (mitigated by Locale.ROOT upper-casing); trailing whitespace or quotes around the value.","solutions":["Check the enum's actual constant names in the JUnit version you target and use the exact name (case-insensitive after normalization).","Strip surrounding quotes/whitespace from the value in junit.properties / -D argument.","If migrating versions, look up the changelog for renamed/removed constants and update accordingly.","The exception message echoes the normalized value it tried — use it to spot typos."],"exampleFix":"// before (junit.properties)\njunit.jupiter.testclass.order.default = classname\n// after\njunit.jupiter.testclass.order.default = ClassName","handlingStrategy":"validation","validationCode":"String raw = configParams.get(key).orElse(null);\nif (raw != null) {\n    String norm = raw.strip().toUpperCase(Locale.ROOT);\n    Set<String> valid = Arrays.stream(enumType.getEnumConstants())\n            .map(Enum::name).collect(toSet());\n    if (!valid.contains(norm)) { /* invalid config value */ }\n}","typeGuard":"static <E extends Enum<E>> boolean isValidEnumValue(Class<E> enumType, String raw) {\n    try {\n        Enum.valueOf(enumType, raw.strip().toUpperCase(Locale.ROOT));\n        return true;\n    } catch (IllegalArgumentException e) {\n        return false;\n    }\n}","tryCatchPattern":"try {\n    Optional<E> v = converter.get(configParams, key);\n} catch (JUnitException e) {\n    // message names the bad value and key; correct junit.properties / -D flag\n}","preventionTips":["Use exact enum constant names (case-insensitive) in junit.properties / -D flags.","Strip quotes/whitespace around config values.","Re-check constant names when upgrading JUnit versions."],"tags":["configuration-parameter","enum-parsing","junit-properties","migration","typo"],"backgroundTag":null,"analyzedSha":"f070c699a08b5d8393df9afd147af5c5e90bb21b","analyzedAt":"2026-08-11T20:31:00.530Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}