{"record":{"id":"22cc1696bc2edaa8","repo":"quarkusio/quarkus","slug":"parameter-mode-was-set-to-mode-while-expecte-22cc16","errorCode":null,"errorMessage":"Parameter 'mode' was set to '<mode>' while expected one of 'dev', 'test' or 'prod'","messagePattern":"Parameter 'mode' was set to '<mode>' while expected one of 'dev', 'test' or 'prod'","errorType":"exception","errorClass":"MojoExecutionException","httpStatus":null,"severity":"error","filePath":"devtools/maven/src/main/java/io/quarkus/maven/DependencySbomMojo.java","lineNumber":146,"sourceCode":"    }\n\n    private ApplicationModel resolveApplicationModel()\n            throws MojoExecutionException {\n        final ArtifactCoords appArtifact = ArtifactCoords.pom(project.getGroupId(), project.getArtifactId(),\n                project.getVersion());\n        final BootstrapAppModelResolver modelResolver;\n        try {\n            modelResolver = new BootstrapAppModelResolver(getResolver())\n                    .setRuntimeModelOnly(runtimeOnly);\n            if (mode != null) {\n                if (mode.equalsIgnoreCase(\"test\")) {\n                    modelResolver.setTest(true);\n                } else if (mode.equalsIgnoreCase(\"dev\") || mode.equalsIgnoreCase(\"development\")) {\n                    modelResolver.setDevMode(true);\n                } else if (mode.equalsIgnoreCase(\"prod\") || mode.isEmpty()) {\n                    // ignore, that's the default\n                } else {\n                    throw new MojoExecutionException(\n                            \"Parameter 'mode' was set to '\" + mode + \"' while expected one of 'dev', 'test' or 'prod'\");\n                }\n            }\n            modelResolver.setLegacyModelResolver(BootstrapAppModelResolver.isLegacyModelResolver(project.getProperties()));\n            return modelResolver.resolveModel(appArtifact);\n        } catch (Exception e) {\n            throw new MojoExecutionException(\"Failed to resolve application model \" + appArtifact + \" dependencies\", e);\n        }\n    }\n\n    private String getSbomFilename() {\n        var a = project.getArtifact();\n        var sb = new StringBuilder().append(a.getArtifactId()).append(\"-\").append(a.getVersion()).append(\"-\");\n        if (!\"prod\".equalsIgnoreCase(mode)) {\n            sb.append(mode).append(\"-\");\n        }\n        return sb.append(\"dependency-cyclonedx\").append(\".\").append(format).toString();\n    }","sourceCodeStart":128,"sourceCodeEnd":164,"githubUrl":"https://github.com/quarkusio/quarkus/blob/e1c734241f34c7919086ceb4c9262b4a58f6de44/devtools/maven/src/main/java/io/quarkus/maven/DependencySbomMojo.java#L128-L164","documentation":"DependencySbomMojo.resolveApplicationModel mirrors DependencyListMojo: the 'mode' parameter must be one of test, dev/development, or prod (empty = default prod). Any other value throws a MojoExecutionException with the invalid value and accepted options. This mojo generates an SBOM, so it fails before SBOM generation starts.","triggerScenarios":"Running quarkus:dependency-sbom with -Dmode set to an unsupported value such as 'production' or a profile name; only checked when mode is configured (the guard sits inside an if block).","commonSituations":"Copying mode values from other tooling/CI environments; typo in the mode property; misunderstandings about accepted aliases (only dev/development/test/prod/empty are accepted).","solutions":["Set mode to dev, test, or prod (or omit it)","Use the exact spelling from the error message","Audit CI scripts that pass mode dynamically and validate the value"],"exampleFix":"// before\nmvn quarkus:dependency-sbom -Dmode=prod-mode\n// after\nmvn quarkus:dependency-sbom -Dmode=prod","handlingStrategy":"validation","validationCode":"// Validate the mode value before invoking the SBOM goal\njava.util.Set<String> VALID = java.util.Set.of(\"dev\", \"development\", \"test\", \"prod\", \"\");\nif (!VALID.contains(mode == null ? \"\" : mode.trim())) {\n    throw new IllegalStateException(\"mode must be one of dev, test, prod (got: \" + mode + \")\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    mojo.execute();\n} catch (MojoExecutionException e) {\n    if (e.getMessage().contains(\"Parameter 'mode' was set to\")) {\n        // re-run with -Dmode=dev|test|prod or omit the property\n    }\n}","preventionTips":["Standardize mode values (dev/test/prod) across all Quarkus mojo invocations","Validate CI-generated mode parameters before passing them via -D","Document accepted aliases (development) to prevent guesswork"],"tags":["maven","configuration","sbom","validation"],"backgroundTag":"invalid-enumeration-value","analyzedSha":"e1c734241f34c7919086ceb4c9262b4a58f6de44","analyzedAt":"2026-09-05T17:01:29.979Z","contentChangedAt":"2026-09-05T17:01:29.979Z","schemaVersion":2},"datasetVersion":"2026-09-12T22:17:10.623Z"}