quarkusio/quarkus · error · MojoExecutionException
Parameter 'mode' was set to '<mode>' while expected one of '
Error message
Parameter 'mode' was set to '<mode>' while expected one of 'dev', 'test' or 'prod'
What it means
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.
Source
Thrown at devtools/maven/src/main/java/io/quarkus/maven/DependencySbomMojo.java:146
}
private ApplicationModel resolveApplicationModel()
throws MojoExecutionException {
final ArtifactCoords appArtifact = ArtifactCoords.pom(project.getGroupId(), project.getArtifactId(),
project.getVersion());
final BootstrapAppModelResolver modelResolver;
try {
modelResolver = new BootstrapAppModelResolver(getResolver())
.setRuntimeModelOnly(runtimeOnly);
if (mode != null) {
if (mode.equalsIgnoreCase("test")) {
modelResolver.setTest(true);
} else if (mode.equalsIgnoreCase("dev") || mode.equalsIgnoreCase("development")) {
modelResolver.setDevMode(true);
} else if (mode.equalsIgnoreCase("prod") || mode.isEmpty()) {
// ignore, that's the default
} else {
throw new MojoExecutionException(
"Parameter 'mode' was set to '" + mode + "' while expected one of 'dev', 'test' or 'prod'");
}
}
modelResolver.setLegacyModelResolver(BootstrapAppModelResolver.isLegacyModelResolver(project.getProperties()));
return modelResolver.resolveModel(appArtifact);
} catch (Exception e) {
throw new MojoExecutionException("Failed to resolve application model " + appArtifact + " dependencies", e);
}
}
private String getSbomFilename() {
var a = project.getArtifact();
var sb = new StringBuilder().append(a.getArtifactId()).append("-").append(a.getVersion()).append("-");
if (!"prod".equalsIgnoreCase(mode)) {
sb.append(mode).append("-");
}
return sb.append("dependency-cyclonedx").append(".").append(format).toString();
}View on GitHub (pinned to e1c734241f)
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
Example fix
// before mvn quarkus:dependency-sbom -Dmode=prod-mode // after mvn quarkus:dependency-sbom -Dmode=prod
Defensive patterns
Strategy: validation
Validate before calling
// Validate the mode value before invoking the SBOM goal
java.util.Set<String> VALID = java.util.Set.of("dev", "development", "test", "prod", "");
if (!VALID.contains(mode == null ? "" : mode.trim())) {
throw new IllegalStateException("mode must be one of dev, test, prod (got: " + mode + ")");
} Try / catch
try {
mojo.execute();
} catch (MojoExecutionException e) {
if (e.getMessage().contains("Parameter 'mode' was set to")) {
// re-run with -Dmode=dev|test|prod or omit the property
}
} Prevention
- 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
When it happens
Trigger: 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).
Common situations: 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).
Related errors
- Unrecognized dependency flag '<trimmed>'. Supported flags: O
- Parameter 'mode' was set to '<mode>' while expected one of '
- Parameter 'mode' was set to '<mode>' while expected one of '
- Manifest entry name ${key} is invalid. " characters are not
- Manifest section name ${section} is invalid. " characters ar
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/22cc1696bc2edaa8.
Report an issue: GitHub.