quarkusio/quarkus · error · IllegalArgumentException
Unexpected value: <arcConfig.optimizeContexts()>
Error message
Unexpected value: <arcConfig.optimizeContexts()>
What it means
The context-optimization switch in ArcProcessor switches over the OptimizeContexts enum (TRUE/FALSE/AUTO); the default branch throws IllegalArgumentException because a new/unmapped enum constant was added without updating the switch.
Source
Thrown at extensions/arc/deployment/src/main/java/io/quarkus/arc/deployment/ArcProcessor.java:412
for (SuppressConditionGeneratorBuildItem generator : suppressConditionGenerators) {
builder.addSuppressConditionGenerator(generator.getGenerator());
}
builder.setBuildCompatibleExtensions(buildCompatibleExtensions.entrypoint);
builder.setOptimizeContexts(new Predicate<BeanDeployment>() {
@Override
public boolean test(BeanDeployment deployment) {
switch (arcConfig.optimizeContexts()) {
case TRUE:
return true;
case FALSE:
return false;
case AUTO:
// Optimize the context if there is less than 1000 beans in the app
// Note that removed beans are excluded
return deployment.getBeans().size() < 1000;
default:
throw new IllegalArgumentException("Unexpected value: " + arcConfig.optimizeContexts());
}
}
});
BeanProcessor beanProcessor = builder.build();
ContextRegistrar.RegistrationContext context = beanProcessor.registerCustomContexts();
return new ContextRegistrationPhaseBuildItem(context, beanProcessor);
}
// PHASE 2 - register all beans
@BuildStep
public BeanRegistrationPhaseBuildItem registerBeans(ContextRegistrationPhaseBuildItem contextRegistrationPhase,
List<ContextConfiguratorBuildItem> contextConfigurationRegistry,
BuildProducer<InterceptorResolverBuildItem> interceptorResolver,
BuildProducer<BeanDiscoveryFinishedBuildItem> beanDiscoveryFinished,
BuildProducer<TransformedAnnotationsBuildItem> transformedAnnotations,
BuildProducer<InvokerFactoryBuildItem> invokerFactory) {
View on GitHub (pinned to e1c734241f)
Solutions
- Upgrade/align the Quarkus BOM so ArcConfig and ArcProcessor come from the same version
- Report a bug to Quarkus if it reproduces on a stock build
- Set quarkus.arc.optimize-contexts=true or false explicitly to avoid the AUTO branch path
Defensive patterns
Strategy: validation
Validate before calling
OptimizeContexts v = arcConfig.optimizeContexts();
if (v != OptimizeContexts.TRUE && v != OptimizeContexts.FALSE && v != OptimizeContexts.AUTO)
throw new IllegalArgumentException("Unsupported optimize-contexts: " + v); Prevention
- Keep Quarkus core modules version-aligned via the BOM
- Handle all enum constants in new switches
- Report missing default branches upstream
When it happens
Trigger: Hitting the switch default branch for an OptimizeContexts value not explicitly handled — normally impossible with only TRUE/FALSE/AUTO, but occurs if a new enum constant is introduced or a custom/patched config value reaches the switch.
Common situations: Running a patched or version-mismatched Quarkus build where ArcConfig gained a new enum constant; bytecode/agent instrumentation altering enum values. Extremely rare for end users.
Related errors
- AnnotationTransformation is not an AnnotationsTransformer: <
- Invalid configuration value set for 'quarkus.arc.remove-unus
- Different default scopes defined for additional bean class:
- A matching predicate must be set!
- 'target' can only be a class, a field or a method: <target>
AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05).
Data as JSON: /api/errors/3215bd6981de3b84.
Report an issue: GitHub.