{"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/956246301e03d757539f7b76dd5a91f298637563/junit-jupiter-engine/src/main/java/org/junit/jupiter/engine/config/EnumConfigurationParameterConverter.java#L43-L67","documentation":"Thrown as a JUnitException by EnumConfigurationParameterConverter.convert when a configuration parameter value (from junit-platform.properties, system property, or launcher ConfigurationParameters) cannot be parsed into the expected enum type. The converter uppercases and strips the value, then calls Enum.valueOf; any failure (illegal constant name) is wrapped. Used for ExecutionMode (parallel execution mode), Lifecycle (test instance lifecycle mode), CleanupMode (cleanup mode), ExtensionContextScope (extension context scope), TimeoutMode (timeout mode), and ThreadMode (timeout thread mode).","triggerScenarios":"Setting a configuration parameter such as junit.jupiter.testinstance.lifecycle.default = PER_METHODS (typo, no such constant), or junit.jupiter.execution.parallel.mode.default = PARALLELL, or junit.jupiter.cleanup.mode.default = stric. Any value that is not an exact (case-insensitive) match of a constant in the target enum.","commonSituations":"Typos in junit-platform.properties; copying a value from outdated documentation; version change where an enum constant was renamed or removed; locale-specific case folding (the converter uses Locale.ROOT so this is rare, but non-ASCII letters would fail).","solutions":["Check the error message for the enumDisplayName (e.g. 'parallel execution mode') and the offending value, then set it to a valid constant of that enum (e.g. PARALLEL, CONCURRENT for ExecutionMode; PER_METHOD or PER_CLASS for Lifecycle; ON_SUCCESS or ON_TRAVERSAL for CleanupMode).","Open the enum's Javadoc (ExecutionMode, Lifecycle, CleanupMode, ExtensionContextScope, TimeoutMode, ThreadMode) and copy a constant name verbatim.","Validate the file against the JUnit version actually on the classpath — constants are occasionally renamed across major versions."],"exampleFix":"// before (junit-platform.properties)\njunit.jupiter.testinstance.lifecycle.default = PER_METHODS\n\n// after\njunit.jupiter.testinstance.lifecycle.default = PER_METHOD","handlingStrategy":"validation","validationCode":"// Validate a config value against its enum before launching JUnit\npublic static <E extends Enum<E>> void validate(Class<E> enumType, String key, String raw) {\n    try {\n        Enum.valueOf(enumType, raw.strip().toUpperCase(java.util.Locale.ROOT));\n    } catch (IllegalArgumentException e) {\n        throw new IllegalArgumentException(\n            \"Invalid value '\" + raw + \"' for \" + key + \". Valid: \" + java.util.Arrays.toString(enumType.getEnumConstants()));\n    }\n}\n// usage: validate(Lifecycle.class, \"junit.jupiter.testinstance.lifecycle.default\", \"PER_METHOD\");","typeGuard":"static <E extends Enum<E>> boolean isValidEnumValue(Class<E> enumType, String raw) {\n    try { Enum.valueOf(enumType, raw.strip().toUpperCase(java.util.Locale.ROOT)); return true; }\n    catch (Exception e) { return false; }\n}","tryCatchPattern":null,"preventionTips":["Copy enum constant names verbatim from the Javadoc of ExecutionMode, Lifecycle, CleanupMode, ExtensionContextScope, TimeoutMode, ThreadMode.","Add a CI check that parses junit-platform.properties and validates enum-typed keys against the JUnit version on the classpath.","After upgrading JUnit, review the release notes for renamed/removed enum constants."],"tags":["configuration-parameter","enum","junit-platform-properties","configuration-error","junit-jupiter"],"analyzedSha":"956246301e03d757539f7b76dd5a91f298637563","analyzedAt":"2026-08-04T19:25:17.049Z","schemaVersion":2}