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

  1. Upgrade/align the Quarkus BOM so ArcConfig and ArcProcessor come from the same version
  2. Report a bug to Quarkus if it reproduces on a stock build
  3. 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

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


AI-assisted analysis of quarkusio/quarkus@e1c734241f (2026-09-05). Data as JSON: /api/errors/3215bd6981de3b84. Report an issue: GitHub.