{"record":{"id":"0edb9f12937c5d8b","repo":"junit-team/junit5","slug":"invalid-discoveryissue-severity-s-set-via-the","errorCode":null,"errorMessage":"Invalid DiscoveryIssue.Severity '%s' set via the '%s' configuration parameter.","messagePattern":"Invalid DiscoveryIssue\\.Severity '(.+?)' set via the '(.+?)' configuration parameter\\.","errorType":"exception","errorClass":"JUnitException","httpStatus":null,"severity":"error","filePath":"junit-platform-launcher/src/main/java/org/junit/platform/launcher/core/DiscoveryIssueCollector.java","lineNumber":58,"sourceCode":"\tpublic void issueEncountered(UniqueId engineId, DiscoveryIssue issue) {\n\t\tthis.issues.add(issue);\n\t}\n\n\tDiscoveryIssueNotifier toNotifier() {\n\t\tif (this.issues.isEmpty()) {\n\t\t\treturn DiscoveryIssueNotifier.NO_ISSUES;\n\t\t}\n\t\treturn DiscoveryIssueNotifier.from(criticalSeverity, this.issues);\n\t}\n\n\tprivate static Severity getCriticalSeverity(ConfigurationParameters configurationParameters) {\n\t\treturn configurationParameters //\n\t\t\t\t.get(LauncherConstants.CRITICAL_DISCOVERY_ISSUE_SEVERITY_PROPERTY_NAME, value -> {\n\t\t\t\t\ttry {\n\t\t\t\t\t\treturn Severity.valueOf(value.toUpperCase(Locale.ROOT));\n\t\t\t\t\t}\n\t\t\t\t\tcatch (Exception e) {\n\t\t\t\t\t\tthrow new JUnitException(\n\t\t\t\t\t\t\t\"Invalid DiscoveryIssue.Severity '%s' set via the '%s' configuration parameter.\".formatted(\n\t\t\t\t\t\t\t\tvalue, LauncherConstants.CRITICAL_DISCOVERY_ISSUE_SEVERITY_PROPERTY_NAME));\n\t\t\t\t\t}\n\t\t\t\t}) //\n\t\t\t\t.orElse(Severity.ERROR);\n\t}\n}\n","sourceCodeStart":40,"sourceCodeEnd":66,"githubUrl":"https://github.com/junit-team/junit5/blob/f070c699a08b5d8393df9afd147af5c5e90bb21b/junit-platform-launcher/src/main/java/org/junit/platform/launcher/core/DiscoveryIssueCollector.java#L40-L66","documentation":"DiscoveryIssueCollector.getCriticalSeverity parses the junit.platform.discovery.issue.severity.critical configuration parameter via Severity.valueOf(value.toUpperCase(ROOT)). Any value that is not a DiscoveryIssue.Severity enum constant (ERROR, WARNING, INFO, etc.) causes the inner parse to throw, which is rethrown as a JUnitException naming the bad value and the property.","triggerScenarios":"Setting junit.platform.discovery.issue.severity.critical to a non-enum string (e.g. 'critical', 'fatal', 'warn', empty, or a typo like 'eror') in junit-platform.properties, system properties, or launcher configuration parameters.","commonSituations":"Typos in the property value; copying a severity name from another framework (TestNG/JUnit 4) that does not exist in DiscoveryIssue.Severity; upgrading JUnit where the enum constants were renamed; leftover config from an old tutorial.","solutions":["Set the value to a valid DiscoveryIssue.Severity constant: ERROR, WARNING, INFO (case-insensitive).","Remove the property to fall back to the default (Severity.ERROR).","Validate the value against DiscoveryIssue.Severity values at startup if you compute it dynamically."],"exampleFix":"// before (junit-platform.properties)\njunit.platform.discovery.issue.severity.critical=critical\n// after\njunit.platform.discovery.issue.severity.critical=ERROR","handlingStrategy":"validation","validationCode":"// Validate the property value against the enum before launching\nString v = config.get(\"junit.platform.discovery.issue.severity.critical\").orElse(\"ERROR\");\ntry { DiscoveryIssue.Severity.valueOf(v.toUpperCase(Locale.ROOT)); }\ncatch (IllegalArgumentException e) { throw new IllegalArgumentException(\"bad severity: \" + v); }","typeGuard":"static boolean isValidSeverity(String v) {\n    if (v == null || v.isBlank()) return true; // default applies\n    try { DiscoveryIssue.Severity.valueOf(v.toUpperCase(Locale.ROOT)); return true; }\n    catch (IllegalArgumentException e) { return false; }\n}","tryCatchPattern":"try {\n    launcher.execute(request);\n} catch (JUnitException e) {\n    if (e.getMessage().contains(\"Invalid DiscoveryIssue.Severity\")) {\n        // remove or correct the property and retry\n    }\n}","preventionTips":["Use only DiscoveryIssue.Severity enum constants for that property.","Omit the property to accept the default (ERROR).","Validate dynamic values against the enum at startup."],"tags":["configuration","discovery-issue","severity","enum-parse"],"backgroundTag":null,"analyzedSha":"f070c699a08b5d8393df9afd147af5c5e90bb21b","analyzedAt":"2026-08-11T20:31:00.530Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}