quarkusio/quarkus · error · IllegalStateException

Only one of runtimeValue, function or assistantFunction is a

Error message

Only one of runtimeValue, function or assistantFunction is allowed

What it means

BuildTimeActionBuildItem.ActionBuilder.function() throws this when a runtimeValue or assistantFunction was already set. An action can only have exactly one backing implementation, so setters are mutually exclusive.

Source

Thrown at extensions/devui/deployment-spi/src/main/java/io/quarkus/devui/spi/buildtime/BuildTimeActionBuildItem.java:169

            return this;
        }

        public ActionBuilder enableMcpFunctionByDefault() {
            this.mcpEnabledByDefault = true;
            return this;
        }

        /**
         * @deprecated Use {@link #enableMcpFunctionByDefault()} instead.
         */
        @Deprecated(forRemoval = true)
        public ActionBuilder enableMcpFuctionByDefault() {
            return enableMcpFunctionByDefault();
        }

        public <T> ActionBuilder function(Function<Map<String, String>, T> function) {
            if (this.runtimeValue != null || this.assistantFunction != null)
                throw new IllegalStateException("Only one of runtimeValue, function or assistantFunction is allowed");
            this.function = function;
            return this;
        }

        public <T> ActionBuilder assistantFunction(BiFunction<Object, Map<String, String>, ?> assistantFunction) {
            if (this.function != null || this.runtimeValue != null)
                throw new IllegalStateException("Only one of runtimeValue, function or assistantFunction is allowed");
            this.assistantFunction = assistantFunction;
            return this;
        }

        public ActionBuilder runtime(RuntimeValue<?> runtimeValue) {
            if (this.function != null || this.assistantFunction != null)
                throw new IllegalStateException("Only one of runtimeValue, function or assistantFunction is allowed");
            this.runtimeValue = runtimeValue;
            return this;
        }

View on GitHub (pinned to e1c734241f)

Solutions

  1. Remove the earlier runtime(...) or assistantFunction(...) call so only function(...) remains
  2. If you want both behaviors, combine them in a single Function instead of setting two

Example fix

// before
builder.runtime(myRuntimeValue).function(this::myFunction);
// after
builder.function(this::myFunction);
Defensive patterns

Strategy: validation

Validate before calling

// pick exactly one implementation before building
if (useRuntimeValue) builder.runtime(rv); else builder.function(f);

Try / catch

try {
    builder.function(f);
} catch (IllegalStateException e) {
    if (e.getMessage().contains("Only one of")) { /* remove conflicting setter */ }
    else throw e;
}

Prevention

When it happens

Trigger: Chaining e.g. builder.runtime(rv).function(f) or calling function() twice on the same ActionBuilder.

Common situations: Refactoring from a runtime-value-backed action to a function-backed one without removing the runtime() call.

Related errors


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