{"record":{"id":"8641ccfc5ae06263","repo":"junit-team/junit5","slug":"invalid-launcherphase-s-set-via-the-s-config","errorCode":null,"errorMessage":"Invalid LauncherPhase '%s' set via the '%s' configuration parameter.","messagePattern":"Invalid LauncherPhase '(.+?)' 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/LauncherPhase.java","lineNumber":38,"sourceCode":"import org.junit.platform.commons.JUnitException;\nimport org.junit.platform.engine.ConfigurationParameters;\n\n/**\n * The phase the {@link org.junit.platform.launcher.Launcher} is in.\n *\n * @since 1.13\n */\nenum LauncherPhase {\n\n\tDISCOVERY, EXECUTION;\n\n\tstatic Optional<LauncherPhase> getDiscoveryIssueFailurePhase(ConfigurationParameters configurationParameters) {\n\t\tFunction<String, @Nullable LauncherPhase> stringLauncherPhaseFunction = value -> {\n\t\t\ttry {\n\t\t\t\treturn LauncherPhase.valueOf(value.toUpperCase(Locale.ROOT));\n\t\t\t}\n\t\t\tcatch (Exception e) {\n\t\t\t\tthrow new JUnitException(\n\t\t\t\t\t\"Invalid LauncherPhase '%s' set via the '%s' configuration parameter.\".formatted(value,\n\t\t\t\t\t\tDISCOVERY_ISSUE_FAILURE_PHASE_PROPERTY_NAME));\n\t\t\t}\n\t\t};\n\t\treturn configurationParameters.get(DISCOVERY_ISSUE_FAILURE_PHASE_PROPERTY_NAME, stringLauncherPhaseFunction);\n\t}\n\n\t@Override\n\tpublic String toString() {\n\t\treturn name().toLowerCase(Locale.ENGLISH);\n\t}\n}\n","sourceCodeStart":20,"sourceCodeEnd":51,"githubUrl":"https://github.com/junit-team/junit5/blob/f070c699a08b5d8393df9afd147af5c5e90bb21b/junit-platform-launcher/src/main/java/org/junit/platform/launcher/core/LauncherPhase.java#L20-L51","documentation":"Thrown as a JUnitException by LauncherPhase.getDiscoveryIssueFailurePhase() when the configuration property 'junit.platform.discovery.issue.failure.phase' cannot be mapped to one of the two enum constants DISCOVERY or EXECUTION. The value is parsed via LauncherPhase.valueOf(value.toUpperCase(Locale.ROOT)), so only 'discovery' and 'execution' (case-insensitive) are accepted. It signals a user-supplied configuration error, not a runtime/environment problem.","triggerScenarios":"Setting the JVM system property or JUnit Platform config file entry 'junit.platform.discovery.issue.failure.phase' to any string other than 'discovery' or 'execution' — e.g. 'none', 'runtime', 'test', 'discovry' (typo), an empty string, or a value copied from the related severity property. The IllegalArgumentException from LauncherPhase.valueOf() is caught and rethrown with this message during Launcher.discover()/execute() initialization.","commonSituations":"Confusing this property with the sibling 'junit.platform.discovery.issue.severity.critical' which accepts Severity names (error, warning, etc.); typo while hand-editing junit-platform.properties; trailing whitespace or quotes around the value in a properties file; copy-pasting a value from outdated docs; version mismatch where the property was introduced in 1.13 but the user reads pre-1.13 guidance.","solutions":["Set the property to 'discovery' or 'execution' (case-insensitive), e.g. -Djunit.platform.discovery.issue.failure.phase=execution.","Remove the property entirely to let the Launcher pick the phase automatically based on whether discover() or execute() is called.","Inspect junit-platform.properties on the classpath and any -D JVM args for typos, surrounding quotes, or trailing whitespace.","If migrating from an older version, confirm the property name and accepted values against the LauncherConstants.DISCOVERY_ISSUE_FAILURE_PHASE_PROPERTY_NAME javadoc for your JUnit version."],"exampleFix":"// before\n-Djunit.platform.discovery.issue.failure.phase=none\n\n// after\n-Djunit.platform.discovery.issue.failure.phase=execution","handlingStrategy":"validation","validationCode":"// Run before launching, against the same ConfigurationParameters / system props.\nString key = \"junit.platform.discovery.issue.failure.phase\";\nString value = System.getProperty(key); // or read from junit-platform.properties\nif (value != null && !value.isBlank()\n        && !\"discovery\".equalsIgnoreCase(value.trim())\n        && !\"execution\".equalsIgnoreCase(value.trim())) {\n    throw new IllegalStateException(\n        \"Invalid \" + key + \"=\" + value + \". Use 'discovery' or 'execution'.\");\n}","typeGuard":null,"tryCatchPattern":"// JUnitException is unchecked; surface a clear config error to the user.\ntry {\n    launcher.execute(request);\n} catch (JUnitException e) {\n    if (e.getMessage() != null && e.getMessage().startsWith(\"Invalid LauncherPhase\")) {\n        throw new IllegalStateException(\n            \"Fix junit.platform.discovery.issue.failure.phase \"\n          + \"(must be 'discovery' or 'execution').\", e);\n    }\n    throw e;\n}","preventionTips":["Treat the property as an enum: only the literals 'discovery' and 'execution' are valid.","Add a preflight config validator in your build plugin that checks junit-platform.properties keys.","Do not confuse this property with junit.platform.discovery.issue.severity.critical, which takes a Severity name.","Pin all JUnit artifacts via junit-bom so the property name and accepted values match your version's docs."],"tags":["configuration","junit-platform","launcher","validation","discovery"],"backgroundTag":null,"analyzedSha":"f070c699a08b5d8393df9afd147af5c5e90bb21b","analyzedAt":"2026-08-11T20:31:00.530Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}